Using selenium2library to automate my web application with robot framework. I am not able to accept a browser alert using the existing keywords.
Getting the below exception while trying to accept the alert.
UnexpectedAlertPresentException: Alert Text: Delete selected trusted provider(s)?
<super: <class 'WebDriverException'>, <UnexpectedAlertPresentException object>>
have tried the below selenium2library keywords Alert Should Be Present
, Get Alert Message
, Confirm Action
, etc.
Please guide me on how to proceed.
At last I have found a way to handle alerts in Robot Framework.
We just have to use "Choose Ok On Next Confirmation" with "Confirm Action" Keyword.
Say if I want to accept an Alert prompting for Yes or No for deleting an resource using selenium you can use the below code.
Choose Ok On Next Confirmation
Click Element //a[contains(.,'Delete')]
Confirm Action
This will be accepting the Alert. If you want to dismiss or deny the alert you can simply use the keyword Alert Should Be Present which will auto dismiss the alert.
As of Selenium2Library 3.0 you can use the Handle Alert keyword with the actions:
There is also an optional 2nd argument that you can use to supply a timeout. It is also possible to store the text from the alert in a variable.
Handle Alert Keyword - Selenium2Library Docs http://robotframework.org/Selenium2Library/Selenium2Library.html#Handle%20Alert
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.