1

I'm exploring Robot Framework for some smoke testing of a site, and at a point have to sign in, which opens a new window. Moving to the new window with Select Window works for me, but I'm bridging this change by identifying the title of Sign In, and the new window does not immediately adopt that title as it loads your login form - sometimes this takes half a second, sometimes more than 5.

I'm working around this right now by having the test sleep for the obnoxiously long period of 10s, but surely there are more reliable ways of ensuring that I can change my target window to the new one, and not have my test fail and exit while the page is loading. I took a shot at using the redirect url as the identifier, but sometimes it redirects very quickly and fails, or if not, then it gets hung up on the next check for the login field that isn't loaded. I've seen commands like Wait Until Element Is Visible, but unfortunately that doesn't help when I can't target the window where things are loading...

For the sake of it:

*** Test Cases ***
Basic Workflow
    Open Browser To Homepage
    Go To Sign In

*** Keywords ***
Open Browser To Homepage
    Open Browser    ${HOMEPAGE}     ${BROWSER}
    Maximize Browser Window
    Set Selenium Speed      ${DELAY}

Go To Sign In
    Click Button    Sign In
    Sleep   10s
    Select Window   Sign In
    Title Should Be   Sign In

Using Selenium2Library currently.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
sm0115
  • 21
  • 1
  • 5
  • Check if you have a step that waits for the page to be loaded and add it after Select Window. Also check this http://stackoverflow.com/questions/36568653/wait-until-the-page-is-loaded – lauda Aug 25 '16 at 20:19
  • Method proposed by lauda is the best. But if you are not able to detect when page is loaded, there is another way: you can write a keyword that tries to select window until it succeeds, ignoring errors – Pekka Aug 26 '16 at 09:35
  • Thanks for responding! The problem isn't so much waiting for elements/the page to load, it's that I'm not sure how to get it to look at the new window that opened so it can assess if it's loaded. My limited knowledge of changing windows right now is dependent upon `Select Window` and titles/urls, but the page that opens auto-redirects, so the title I'm relying on isn't reliably present right away.necessitating that I have it sleep, and hope that 10 seconds is enough for it to load (usually 2 is fine, but not always). – sm0115 Aug 26 '16 at 15:52

1 Answers1

1

lauda had it right in writing out a Keyword for managing the Select Window. I found Wait Until Keyword Succeeds and made a keyword for it to wait on.

Go To Sign In
    Click Button    Sign In
    Wait Until Keyword Succeeds   20s   3s    Switch To Sign In Page
    Title Should Be   Sign In

Switch to Sign In Page
    Select Window     Sign In

Thank you, both!

sm0115
  • 21
  • 1
  • 5