2

I run a test where I have to dismiss a warning that is a DIV that overlays the whole page. First I send a click to a button that adds something, then a warning is displayed. Finally I enter a string in a field

The code looks something like this

SeleniumLibrary.Click element  add_button
Wait Until Element is visible  warning-overlay-div
SeleniumLibrary.Click element  dismiss-warning
SeleniumLibrary.Click element  something-else

Running this code results in an error message:

WebDriverException: Message: unknown error: Element <input type="text" class="upperCaseClass modified" id="something-else" maxlength="15" style="width: 143px; text-transform: uppercase;"> is not clickable at point (230, 679). Other element would receive the click: <div class="warning-overlay-div" style="width: 100%; height: 853px; z-index: 2003;"></div>

That is, I can't click in something-else because warning-overlay-div is on top of it.

Ok, so I added a check to make sure the warning-overlay-div is gone between the the click dismiss-warning and the click on something-else. I have tried multiple variants but these three all give the same result

(from the log)

00:00:15.050KEYWORD SeleniumLibrary . Wait Until Element Is Not Visible ${warning-overlay-div}
00:00:15.003KEYWORD SeleniumLibrary . Wait Until Page Does Not Contain ${warning-overlay-div}
00:00:15.039KEYWORD SeleniumLibrary . Wait Until Page Does Not Contain Element ${warning-overlay-div}

It might take half a second or so for the overlay to disappear but as you can see, all these wait until they timeout after 15 seconds before they return success. I want to continue as soon as the warning-overlay-div is gone, not wait 15 seconds for that.

How do I check that this overlay is gone and then immediately continue?

Bence Kaulics
  • 7,066
  • 7
  • 33
  • 63
  • 1
    I would try `Wait Until Page Does Not Contain `. Make sure to pass the text of the `div` and not the web element itself. – Bence Kaulics Nov 30 '18 at 19:15
  • 1
    The set of keywords `Wait Until *` do not wait/sleep for 15 seconds, they do return control immediately when their condition is fulfilled. It's very strange the 3 of them are taking precisely 15 seconds to finish - are you sure they do succeed, but not fail at their timeout? – Todor Minakov Dec 01 '18 at 12:51
  • @todor The log shows green but I am absolutely not sure. In fact, I was surprised it worked. All other attempts I have tried (such as sleep) failed with the same error message as above. Do these Wait Until * return something I could look at? –  Dec 01 '18 at 19:01
  • As mentioned by @Todor I'm surprised that they take 15 seconds, exactly. Using a custom keyword that clicks the element and surround it with `Wait untill keyword succeeds` occasionally is a working approach. – A. Kootstra Dec 01 '18 at 19:23
  • I think I read somewhere that the default timeout is 15 seconds? See the Timeout section here http://robotframework.org/Selenium2Library/Selenium2Library.html –  Dec 02 '18 at 10:07
  • Evan so, this is the timeout when the keyword "gives up" to wait on the condition, and fails – Todor Minakov Dec 02 '18 at 14:32

1 Answers1

3

You could potentially try using "Wait Until Keyword Succeeds" allowing yourself a custom retry timeout. Especially useful if you want to ensure the warning is removed from display in an appropriate amount of time.

 Wait Until Keyword Succeeds  ${retry}  ${retry-interval}  Element Should Not Be Visible  ${warning-overlay-div}   

${retry} = the amount of time overall to perform the check

${retry-interval} = the time between each retry

Time Formats

(I would have made this just a comment but I cannot until I have 50rep - this is just something that might be worth trying)

Matthew King
  • 624
  • 4
  • 11