Forum Discussion

scottroutesmart's avatar
Occasional Contributor
2 years ago

Faster Methods to Find Child Objects

I am trying to find a way to improve the speed of my tests overall.   The drop down menus we have are not SELECT html drop downs with OPTION tags, but instead are layered DIVs (since our sites use React).  So, I have found the best way to search/click on the desired option is to pass in the list of available options from the drop down, and then find the correct child element to click upon.

Currently I am using a FindChild() method to identify and click the desired option:



function ClickOnSelectBoxOption(SelectBoxOptionsList, OptionToSelect) {
  SelectBoxOptionsList.FindChild("contentText", OptionToSelect).Click();



But I thought it was running a little slow, so I tried to use the FindChildByXpath() method:



function ClickOnSelectBoxOption(SelectBoxOptionsList, OptionToSelect) {
 SelectBoxOptionsList.FindChildByXPath("DIV[contains(., OptionToSelect)]").Click();



After running the test both ways a few times, when using XPath the test runs ~30 seconds slower than the FindChild function.

Has anyone found a faster way to find and click objects which are layers upon layers of embedded DIVs?

1 Reply

  • rraghvani's avatar
    Champion Level 3

    For example, to find Cell(5, 1) try and use its parent i.e. Table(0) as opposed to e.g. Panel("container"). Also, specifying the Depth value may increase the find.


    As the DOM tree structure becomes larger, certain methods will become slower.