What Browser Library call to detect web-based error message?

I have a Robot Framework test that connects with a web-site and during test execution, a web-based message box appears asking user to either click “Try Again” or “Cancel”.
I have 2 questions:

  1. Using the Browser Library, how do I detect this web-based message box has appeared? The web-based message is very difficult to reproduce. I’ve not been successful trying to reproduce it without automation.
  2. How would I click the “Try Again” or “Cancel” buttons?
    The Selenium Library has Keywords to solve this kind of problem, but I’m using the Browser Library.
    I’m just not sure how to proceed.

I’ve attached a JPG to show what I see.


I do not understand on which level you have an issue.

Click is the keyword to click on something.

You need the selector of the message box.

If you want to check if the message box is visible, you may use Get Element States and check if it is visible.

Something like this:

${error_visible}    Get Element States    id=error_msg    evaluate    bool(value & visible)
IF    $error_visible
    Click    id=error_msg >> "Try Again"

Or please describe a bit more what is puzzling you. Or how you would solve it in SeleniumLibrary.

Hi Rene,
I’m thinking what I’m seeing is an Alert Confirmation Message, and I believe it is “modal” (i.e. does not permit the user to interact with the UI until either “Try Again” or “Cancel” is pressed).
What is difficult is to determine how to detect if I have an Alert Confirmation Message present on the screen.
I’ve seen Python Selenium solutions that say:

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException

browser = webdriver.Firefox()

    WebDriverWait(browser, 3).until(EC.alert_is_present(),
                                   'Timed out waiting for PA creation ' +
                                   'confirmation popup to appear.')

    alert = browser.switch_to.alert
    print("alert accepted")
except TimeoutException:
    print("no alert")

I also saw the Robot Framework SeleniumLibrary keywords that seem to be able to detect if an Alert is present in the browser window:

Not sure if all that was helpful, but that’s what I’ve learned.


This is not an alert!

This is an alert W3Schools Tryit Editor

It is “just” a normal html element.
A modal is also just an html element that is on top of all others and have a semi transparent overlay around it. at least from the automation point of view.

So just open the dev tools and get its locator.


Hi Rene,
You were right that what I was seeing was a normal HTML element on top of all the others with a semi transparent overlay! Thank you for teaching me that!
I have implemented your previously posted algorithm as the solution, and I’ve learned a new way to detect HTML elements using your posted example!
Thank you for explaining so well what I was dealing with!
I’m loving Browser Library - 5 stars for all the hard work you guys have done! :+1:

1 Like