Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

Selenium Robot Framework Alert Example

In this example, you will learn how to use Selenium2Library to handle Alerts in web application testing. Selenium2Library has keywords: Alert Should Be Present and Get Alert Message.

 

Step 1: launch RIDE console, add a resource file named "resource.txt". In this resource file, import Selenium2Library and OperatingSystem library. Add a variable ${Browser}=Firefox.  This resource file will be used in the test.

When view the resource.text in the "Text Edit" view, it looks like this.

Step 2: add a new Suite named "Alertkeywords". In this suite, import the resource.txt file as Resource and add a test case named "AlertTest".

Test Case Keywords view looks like this

*** Settings ***
Resource          ../resource.txt

*** Test Cases ***
AlertTest
    Open Browser    http://www.seleniummaster.com/robotframeworktest/alerttest.html    ${Browser}
    Sleep    5s
    Click Button    name=alert_button
    sleep    5s
    Alert Should Be Present    This is an alert box
    Close Browser

Step 4: run the test as pybot and see the result. Test passed. see the result file at this location below.

http://www.seleniummaster.com/robotframeworktest/report-20140704-212033.html