TestComplete not finding object using QuerySelector
I seem to be having problems when trying to use QuerySelector. I've had this working in the past, but sometimes scripts that I have had working just seem to stop working, despite there being no changes to the html code.
In this scenario I already have located an element in the DOM and passed this element to a variable. I am then trying to use QuerySelector on this variable to further refine what I am looking for. Here is the script I have which is written in Python:
def selectFromDropdown(PropertyNameId,value): openDropdown(PropertyNameId) propNames = ["tagname","className"] propValues = ["DIV","lae-dropdown-options expanded "] DropdownOptions = Aliases.browser.WebApp.FindChild(propNames,propValues,2,True) DropdownOptions.QuerySelector('p[data-option-value="'+value+'"]').scrollIntoView() DropdownOptions.QuerySelector('p[data-option-value="'+value+'"]').Click()
This code is opening a dropdown menu and then selecting a specific option from within that dropdown. The dropdowns being used are custom dropdowns so may work slightly differently to normal ones. Below is the section of the HTML code thats being searched:
<div class="lae-dropdown-options expanded " style="left: 1547px; top: 387.22px; width: 324px; bottom: auto;"> <p class="lae-dropdown-option " data-ember-action="9443" data-option-value="default"> <!----> <span class="field ">Default</span> </p> <p class="lae-dropdown-option " data-ember-action="9439" data-option-value="Red"> <!----> <span class="field ">Red</span> </p> <p class="lae-dropdown-option " data-ember-action="9435" data-option-value="Green"> <!----> <span class="field ">Green</span> </p> <p class="lae-dropdown-option " data-ember-action="9431" data-option-value="Blue"> <!----> <span class="field ">Blue</span> </p> <div style="width: 0px; height: 0px; -ms-overflow-y: hidden;"> </div> </div>
As you can see from the Python script I am first locating the DIV which has the className "lae-dropdown-options expanded " which gets passed into the variable DropdownOptions, this part works fine. I then want to use QuerySelector to find the elements within the object I passed into the variable, which has the attribute data-option-value, which is this part in the Python script
DropdownOptions.QuerySelector('p[data-option-value="'+value+'"]').Click()
This part just won't locate the object, so then obviously doesn't perform the click method. This has worked in the past but has just stopped working, and I have had similar occurrences like this with some other scripts.
Does anyone know if this should work the way I have it, or if I should be approaching this in different way?