1
votes

My Robot Framework tests with Selenium2Library occasionally get stuck waiting for a browser page to fully load a server response, which causes the tests to hang indefinitely at times. In most of these cases I am experiencing, the browser has loaded 99% of the content and can be interacted with just fine. However, the automation will not proceed until the browser load comes to a complete stop.

When I have watched the automation tests run and encounter this browser hanging issue, if I manually press the browser "stop" button, the browser stops loading and the automation tests resume as normal. I would like to automate this browser stop in situations when the browser hangs but not have it slow down the tests when the browser loads as expected.

I see there is a Selenium Webdriver command in Python called set_page_load_timeout() which looks like it may be what I'm looking for if I can figure out how to use it within Robot Framework.

Another option I have been looking at is executing javascript to force stop the browser load, like so:

***Keywords***
Stop browser load
    Execute Javascript    return window.stop();

However with a command like the one above, the question comes as to how to implement it and recognize when a browser load is taking too long. I don't want to set unnecessary timeouts for each time a new page is loaded or a link is clicked, as that would cause the overall running of the tests to slow down.

Does Robot Framework's Selenium2Library have anything like this already built in where you can set the actual page load time of a server response so the tests can recognize when the browser is still in a loading state? I have been reviewing the Selenium2Library documentation and have not found anything directly related to this.

Any help would be greatly appreciated, thank you.

1

1 Answers

0
votes

You can use Robotframework Timeout. You can put timeout in your Setting or in Keyword.

In Keyword:

*** Keywords ***
Timed Keyword
    [Documentation]    Set only the timeout value and not the custom message.
    [Timeout]    1 minute 42 seconds
    Do Something
    Do Something Else


In Settings:

*** Settings ***
Test Timeout    5 seconds