SeleniumHQ / selenium-ide

Open Source record and playback test automation for the web.
https://selenium.dev/selenium-ide/
Apache License 2.0
2.83k stars 768 forks source link

Can not use command "select" to operate a dropdown list #1848

Open heandping opened 4 months ago

heandping commented 4 months ago

Im using selenium IDE is 4.0.1-beta.13, chrome is Version 126.0.6478.127 (Official Build) (arm64)

Try to select from dropdown list, but failed here

image

Here is the page DOM

image

Error pasted here: 0:38:46 AM [warn] [ 'Unexpected error occured during command:', 'select-xpath=//select[@name="perPageSelect"]-label=30', 'retrying...' ] 10:38:46 AM [error] [ no such element: Unable to locate element: {"method":"xpath","selector":".//option[. = '30']"}\n + ' (Session info: chrome=120.0.6099.291)' ] 10:38:50 AM [debug] [ 'Playing state changed errored for test I009 - Alter the number of the displayed items per page' ] 10:38:50 AM [debug] [ 'Releasing window for playback' ] 10:38:50 AM [error] [ Error: Operation timed out during select:xpath=//select[@name="perPageSelect"]:label=30 at Timeout._onTimeout (/Users/heyong/.nvm/versions/node/v16.20.2/lib/node_modules/selenium-ide/build/webpack:/side-runtime/src/playback-tree/command-node.ts:187:13) at listOnTimeout (node:internal/timers:569:17) at processTimers (node:internal/timers:512:7) ] 10:38:50 AM [error] [ 'Command failure:', 'select-xpath=//select[@name="perPageSelect"]-label=30' ]

toddtarsi commented 4 months ago

@heandping - Idk why but could you see if value=30 works better than label=30?

heandping commented 4 months ago

@toddtarsi , Thanks for the suggestion, I will try to use value instead of label

heandping commented 4 months ago

Yes, select locator value=30 can work now, just curious why label fails, anyway this doesn't block me.

toddtarsi commented 3 months ago

@heandping - To give you some idea, first we use a selector to get the element reference. From there, each option strategy does something different to get the child locator. For label, which I've struggled with, we have to use xpath. This is my xpath to go from the select to the option:

".//option[. = '30']"

It's supposed to go like one child down and check for a text match? I suck at xpath, but I bet I need some crud like this on the . part in the bracket.


".//option[normalize-space(translate(., '${nbsp}', ' ')) = '30']" 
toddtarsi commented 3 months ago

Yeah, circling back on this. I bet it's that space before and after 10, 30, 50, and 100. I think I'll just make a test for this permutation. Should be easily fixed in core.