'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!



Solution 1:[1]

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}

Solution 2:[2]

You could use the keyword below from SeleniumLibrary, which will wait for a given time ${timeout} or until the page contains the element.

Wait Until Page Contains Element    ${locator}    ${timeout}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Manish Kumar
Solution 2 Ruben