Get Elements should not raise timeout exception when no elements found. It should return an empty list.
See original GitHub issueIs your feature request related to a problem? Please describe. Selectors can match multiple targets. Currently Get element just “randomly” returns the first match. This might not be the correct thing. Get Element is used so that further manipulations or validations can be made to that element. Selector might match 0, 1 or N elements.
Describe the solution you’d like
Replace Get Element with Get Elements that returns a list of matches. Also have assertion engine there for easy manipulation of that list such as Get Elements selector then value[0]
Describe alternatives you’ve considered Get Element might also raise an error when multiple matches.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
Why does Selenium give a timeout exception if an element is ...
So driver will wait for that time and then if driver is not able to find that element on the page, it will...
Read more >[Question]: null or exception in case if element not found #2063
And I faced strange behavior in case of element not found. When I query element by locator like. await page.QuerySelectorAsync("any locator");.
Read more >How to continue script when element is not found in selenium
Use findElements instead of findElement . findElements will return an empty list if no matching elements are found instead of an exception.
Read more >Built-in Exceptions — Python 3.11.1 documentation
This exception is raised when a system function returns a system-related error, including I/O failures such as “file not found” or “disk full”...
Read more >RPA.Browser library | Robocorp documentation
An absolute path to the created element screenshot is returned. ... text check if alert includes text, will raise ValueError is text does...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, in my opinion Get Elements should allow to return an empty list instead of raising “Could not find element with selector
XXX
within timeout.” exception, just like SeleniumLibraryMaybe I just need to set the timeout to 0… 🤪