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.
How to Handle Javascript Alert, Confirm and Prompt in Robot Framework. Javascript Confirm: It will have some text with 'OK' and 'Cancel' buttons. Javascript Prompt: It will have some text with a text box for user input along with 'OK' and 'Cancel' buttons. – Handle JS Alerts: Test Case Name.
You just have to identify the stop point, which in your example looks like it would be the hyphen between the two number values. for example: to extract the last five digits of this string ABC12345 you would want to create a variable to assign the text to.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With