How to fix "Element with locator not found" in robot framework
The error is telling you it can't find the element.
There are several reasons that could happen. It could truly not be on the page. Or, it could be that it's not initially on the page but is added asynchronously at some point after your test runs. Or, the element could be inside an iframe. Or, you could be on a different page than you are assuming you're on due to an error or a redirect that you didn't anticipate.
Each of those problems requires a different solution. You may simply have an incorrect locator, in which case you need to determine what the correct locator is and use it instead. Or, you may need to call Wait until page contains element before calling input text
. Or, you might need to call Select frame to switch to an embedded frame. Or, you might need to verify you are on the correct page before calling input text
.
ml33
Updated on June 04, 2022Comments
-
ml33 almost 2 years
I need to write a script where I can search with a keyword and test if a certain subject will show but I cannot manage to get the search id. This is my script.
*** Settings *** Library SeleniumLibrary Suite Setup Go to homepage Suite Teardown Close All Browsers *** Variables *** ${HOMEPAGE} https://www.mdh.se/utbildning/kurser ${BROWSER} chrome *** Test Cases *** Google cloud and find Industrial Systems in Cloud Computing Google and check results cloud Industrial Systems in Cloud Computing *** Keywords *** Google and check results [Arguments] ${searchkey} ${result} Input Text id=occasionsTableen_UK_filter ${searchkey} Wait Until Page Contains ${result} Go to homepage Open Browser ${HOMEPAGE} ${BROWSER}
And this is the error message
Google cloud and find Industrial Systems in Cloud Computing | FAIL | Element with locator 'id=occasionsTableen_UK_filter' not found.
-
Rotrak over 4 yearsTried simply to remove the 'id='? Does that help?
-
ml33 over 4 yearsElement with locator 'occasionsTableen_UK_filter' not found. @Rotrak Thats what it says now
-
M.M. over 4 yearsyou could you try it with xpath://*[@id="occasionsTableen_UK_filter"]/label/input
-
-
ml33 over 4 yearsWhen I inspect the search bar this is what I get and thats why I dont know how to call it as it doesnt have a name or id. @asprtrmp
<input type="search" class="" placeholder="Search courses" aria- controls="occasionsTableen_UK">
-
asprtrmp over 4 yearsFor me the element's attribute is
occasionsTablesv_SE
. But you can use xpath based on attribute value, e.g, the locator usage in Selenium would be likexpath=//input[@aria-controls='occasionsTablesv_SE']
-
George Wurthmann over 3 yearsIn my case the age use an iframe.