Forum Discussion
I may be missing something here, but you say:
"In this scenario I already have located an element in the DOM and passed this element to a variable"
But in your code, your search for the dropdown elements is against:
DropdownOptions = Aliases.browser.WebApp.FindChild(propNames,propValues,2,True)
Where is "WebApp" coming from? I don't see it being passed into your function anywhere? Unless you have scoped it globally and assign it elsewhere? (Messy!) If "PropertyNameId" is your top level object, then you only seem to be using that to actually open the dropdown (assuming "openDropdown(PropertyNameId)" is another function which does exactly that?) that reference doesn't seem to be used in the search within the elements.
You are only telling it to search two layers deep within "WebApp" (whatever it is) so maybe it's finding the wrong top level element on the page (may be hidden?) so never finds the values you want? (And this may happen inconsistently depending on the state of other parts of the site at any given time I guess?)
- Hazey10 years agoOccasional Contributor
Thanks for the reply Colin.
'WebApp' is actually part of the name map, and just refers to the actual web page. So I am then looking within the page for the drop down options. The drop down options I'm looking for are at the top of the DOM so that's why I limited the tree level to 2. The openDropdown is a separate function and this part works fine. The drop down options only appear in the DOM once the drop down is expanded. So I essentially am searching within the page for the element that contains the drop down options, which gets passed into a variable of the type object. This part seems to work as when I debug through the script I can see the variable has a object assigned to it. Manually looking through the object I can find the values I am expecting, so I know its found the correct element in the DOM. So once I have found the drop down options element and assigned it to the variable 'DropdownOptions', I then want to search this variable object using the QuerySelector funciton, which should find the individual drop down option I'm looking for.
The issue with all of this really is that it was working. I'm not sure if the QuerySelector function is a little unreliable, or the element isn't being stored properly in the object variable, so I then can't find what I'm looking for.
- Colin_McCrae10 years agoCommunity Hero
Ah right.
OK. I think I misinterpreted part of that slightly.
So DropdownOptions contains the top level DIV. But the QuerySelector, when applied to it, does not find the selection you want?
In which case, I'm out of answers at this point I'm afraid. QuerySelector is not a method I've used personally (in TC) so I know nothing about it. I have used CSS Selectors with Selenium Python bindings before, but only within Selenium world and I'm pretty rubbish with CSS notation so had to get a chunk of help from the devs. Your notation looks about right to me, but then, as I say, I'm pretty rubbish with CSS notation! :smileyembarrassed: