Forum Discussion

msaunders's avatar
msaunders
Contributor
10 years ago

Embeddable Text boxes

I am running in to an issue with embeddable text boxes



i created a routine that sets the text of a text box in an infragistics ultragrid. It works fine when i run it by its self, always passes. But if i run it right after using a similar text box from a different grid, it fails saying it can't find the text box. 



I set it so that the variables are not named the same but as you can see they call similar items



viewText = ultraGridViewpoint.ultraGrid1_EmbeddableTextBox;

textCLT = ultraGridCLT.ultraGrid1_EmbeddableTextBox;



They have very similar object spys:



MainForm.outer_splitContainer.SplitterPanel.sceneControlsPanel.innerPanel_left.activeControl.m_itemPanel.ViewGrid.panel1.ItemGrid.ultraGrid1



MainForm.outer_splitContainer.SplitterPanel.sceneControlsPanel.innerPanel_left.activeControl.m_itemPanel.CltGrid2.ItemGrid.ultraGrid1



I am not sure how to flush out between steps, they seem like hard paths that should work but yet it fails everytime. I found this true in the past and just worked around it, but i have to get it to work this time. The other times i noticed it was when i was trying to set text in other cells of the same ultragrids. Maybe i am going at it all wrong?

5 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3
    I would edit ViewGrid and CitGrid in the name mapping and look for a property that is unique in each path, then add that to the mapping, just to make sure that TestComplete can tell them apart.  Look for something like Name or Text or ID that is not likely to change, rather than Index or similar numbers.



    I might also do it for both of the ItemGrid entries, but usually it's one of the parents name mapping that 's causing the problem.
  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Mathew,

     


    Seeing indexes (1,2) in the name of the mapped objects makes me think that the Index property is used to map them. This property value may change from run to run. That's why, that's not a reliable way to map objects.


    To better understand exactly what is wrong in your case, could you please provide the full description of the error you get located in Test Log's Additional Info tab?


     

  • This is the code leading up to the failure:




      panelLeft.ultraSplitter_Left.Drag(2, 137, 410, 31);


      ultraGridCLT = panelLeft.activeControl.m_itemPanel.CltGrid2.ItemGrid.ultraGrid1;


      ultraGridCLT.ClickCellXY(0, "Model", 104, 12);


      ultraGridCLT.ClickCellXY(0, "Scale", 66, 8);


      textCLT = ultraGridCLT.ultraGrid1_EmbeddableTextBox;


      //set the scale


      textCLT.SetText("10"); <----this is the failure line



    The additional info is in the attached images and so is the tree name mapping. 





    This is the object spy for the box i want



    Aliases.ScenarioEditor.MainForm.outer_splitContainer.SplitterPanel.sceneControlsPanel.innerPanel_left.activeControl.m_itemPanel.CltGrid2.ItemGrid.ultraGrid1.ultraGrid1_EmbeddableTextBox



    If i run this code stand alone it works but when i run this before it, then it fails:




      ultraGridViewpoint = viewGrid.panel1.ItemGrid.ultraGrid1;


      ultraGridViewpoint.Click(15, 75);


      ultraGridViewpoint.Expand(2);


      viewText = ultraGridViewpoint.ultraGrid1_EmbeddableTextBox;


      ultraGridViewpoint.wChildView(2, "Position").ClickCellXY(0, "Coordinates", 61, 14);


      viewText.SetText("4698396.875547 4313247.721288 -40566.849034");


      ultraGridViewpoint.wChildView(2, "Position").ClickCellXY(0, "Yaw", 4, 7);


      viewText.SetText("223.4");


      ultraGridViewpoint.wChildView(2, "Position").ClickCellXY(0, "Pitch", 44, 9);


      viewText.SetText("-23.8");



    You can see in the name mapping the viewgrid and the cltgrid info. I am kind of stumped how they can interfere with each other? Maybe i am doing something dumb and naive though, i am very new to this. I hate that it works stand alone but doesnt in sequence so i think the key is in there somewhere.




    EDIT:

    i see the attached file is to small to read so 




    Tested object:


    Aliases.ScenarioEditor.MainForm.outer_splitContainer.SplitterPanel.sceneControlsPanel.innerPanel_left.activeControl.m_itemPanel.CltGrid2.ItemGrid.ultraGrid1.ultraGrid1_EmbeddableTextBox


    (Sys.Process("ScenarioEditor").WinFormsObject("MainForm").WinFormsObject("outer_splitContainer").WinFormsObject("SplitterPanel", "", 2).WinFormsObject("sceneControlsPanel").WinFormsObject("innerPanel_left").WinFormsObject("activeControl").WinFormsObject("m_itemPanel").WinFormsObject("CltGrid", "", 4).WinFormsObject("ItemGrid").WinFormsObject("ultraGrid1").WinFormsObject("ultraGrid1_EmbeddableTextBox"))

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)
    Hi Mathew,

     


    It's not clear from your screenshot what mapping criteria you are using. Please make sure that there are not properties whose values are changed from run to run.


     


    Let's try modifying your code a bit. As far as I understand, the Scale and Model items are expended when you click them, right? Is the problematic text box located inside this expandable area? Let's add the WaitAliasChild method to wait until the object is fully loaded after appearing on the screen and to obtain it:


     




    ultraGridCLT = panelLeft.activeControl.m_itemPanel.CltGrid2.ItemGrid.ultraGrid1;


    ultraGridCLT.ClickCellXY(0, "Model", 104, 12);


    ultraGridCLT.ClickCellXY(0, "Scale", 66, 8);


    ultraGridCLT.Refresh(); ultraGridCLT.RefreshMappingInfo();


    textCLT = ultraGridCLT.WaitAliasChild("ultraGrid1_EmbeddableTextBox", 4000);


    //set the scale


    if (textCLT.Exists)


      textCLT.SetText("10"); 




     


     


    Does this work?

  • No luck still says the window is invisible  and thus cannot be activated. I was thinking something along the lines of refresh just not sure what to use. Thank you for helping me, i know its hard to understand what i am say and you are doing really well at directing me. Is there any other info that would be helpful that i could pass along?