Elements are not found in many cases

I have several cases where Robot Framework informs me that a specific element can not be found.

In this case the id=searchWidget-input (I have also tried the full xpath, but this does not change anything).

The XML starts with a Javascript must be enabled in order to view the Top time travel app.

Everything below this, i.e. in the div id=”root”, is not ‘available’ for Robot Frameworks.
In some situations, this is solvable to use Select Frame to make the elements visible for Robot Framework. In other cases (like this one) does not have (i)frames however. Does anyone have an idea how to get around this?

There are 2 web testing libraries for robot framework, you didnt specify which one you are using nor did you share any code that could give hints..

with all of this, i’d say “Its in shadow root and fixing the issue depends on which library you are using”.

I’m only using Selenium Library and I did specify that in the commands (SeleniumLibrary.Click Element, etc.). The XML starts with this:

The code is this:
SeleniumLibrary.Open Browser ${URL} ${BROWSER}
SeleniumLibrary.Maximize Browser Window
SeleniumLibrary.Wait Until Page Contains Element id=ggcSearchInput
SeleniumLibrary.Input Text id=ggcSearchInput 3825EE
SeleniumLibrary.Wait Until Page Contains Element id=ggcSuggestionList-9
SeleniumLibrary.Click Element id=ggcSuggestionList-9
SeleniumLibrary.Wait Until Page Contains Beschikbaar voor dit adres
SeleniumLibrary.Wait Until Page Contains Meest bekeken en besteld
SeleniumLibrary.Scroll Element Into View id=card_heading_product-riV7E6GW8OG6Topotijdreis.nl
SeleniumLibrary. Click Element id=card_heading_product-riV7E6GW8OG6Topotijdreis.nl
.

SeleniumLibrary.Click Element    id=searchWidget-input
SeleniumLibrary.Input Text    id=searchWidget-input    Amersfoort
SeleniumLibrary.Click Element    id=searchWidget-suggestion-item-0
SeleniumLibrary.Click Element    xpath=//*[@id="root"]/div/div[2]/div[1]/button

It fails at line SeleniumLibrary.Wait Until Page Contains id=searchWidget-input.

Hi,

First if you’re using only Seleniumlibrary, you could remove it in front of each kwd call to enhance readability.

Then for your issue you’re waiting that the page contains text “id=searchWidget-input”, which might never happen.

You should use Wait Until Page Contains Element or Wait Until Element Is Visible with you id=… locator

Regards
Charlie

1 Like