Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set timeout for "Page should contain element" in Robot Framework / Selnium when using "Create Webdriver"

I'm having an issue with the "Page should contain element" keyword in combination with the "Create webdriver" keyword.

For example, using the "Open browser" keyword, I open a browser, search for an item, then say "Page should contain element". In this case, the test case will wait x seconds, and only fail if the element is not there at that point.

However, if I open the browser using the "Create webdriver" keyword, the "Page should contain element" keyword will not wait x seconds, it fails immediately if the element is not there.

In case my method to open the browser is the issue, this is how I do it:

Open Chrome with extension
    ${ChromeOptions} =    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${ChromeOptions}    add_extension    ${EXECDIR}${/}ChroPath.crx
    ${Options}=    Call Method    ${ChromeOptions}    to_capabilities
    Create Webdriver    Chrome    desired_capabilities=${Options}
    Go to    ${ENV_URL}

I've double checked the timeouts by doing

    ${implicit}=    Get Selenium Implicit Wait
    ${speed}=    Get Selenium Speed
    ${timeout}=    Get Selenium Timeout

and the values returned are the same regardless of whether I have open browser or create webdriver.

Any help would be appreciated!

like image 454
Geoff Avatar asked Sep 21 '25 08:09

Geoff


1 Answers

use below keyword it will wait for 30s maximum and every 5s verify the text is visible. (seconds are your choice, so you can modify as per your need)

Wait Until Keyword Succeeds    30s    5s    Page Should Contain    ${text}
like image 134
Manish Kumar Avatar answered Sep 23 '25 15:09

Manish Kumar