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:
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.
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.
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()
browser.get("url")
browser.find_element_by_id("add_button").click()
try:
WebDriverWait(browser, 3).until(EC.alert_is_present(),
'Timed out waiting for PA creation ' +
'confirmation popup to appear.')
alert = browser.switch_to.alert
alert.accept()
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:
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.
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!