How can I access child nodes? It is worth noting that the resulting children of HTML elements vary in Squish, depending on the browser used. We
directly mirror the DOM from the browser's web page, and some browsers provide extra child
elements for text that occurs between the HTML elements — even if it is just whitespace.
Squish can't filter out NODE elements for backwards compatibility reasons. This is one reason
that it is important to tell support which browser you are testing with.
If you want to print only the selected element from your drop down element try code like this def main ():
startBrowser ( "https://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml_option" )
widget = waitForObject ({ "tagName" : "SELECT" })
test . log ( "Selected index: %d : %s " % ( widget . selectedIndex ,
widget . selectedOption ))
snooze ( 1 )
options = get_select_options ( widget )
snooze ( 1 )
for option in options :
# print only selected elements
if option . property ( "selected" ) == "true" :
test . log ( "Selected option: " + option . innerText )
def get_select_options ( widget ):
options = []
xpath_result = widget . evaluateXPath ( "//option" )
count = xpath_result . snapshotLength
for i in range ( count ):
item = xpath_result . snapshotItem ( i )
options . append ( item )
return options
Copyright © 2024 The Qt Company Ltd. All rights reserved.
Privacy Policy Usage Data Processing by Google We would like to use Google Analytics to get a better understanding of how
you use the website.
By agreeing to this, your usage data will be stored in the USA and processed
by Google LLC. Both Google as well as federal US agencies can access this data
and combine it with any other data about you, such as your search history,
personal accounts or any other data known to Google.
See our privacy
policy to toggle this feature and to learn more, or contact
us .