First Selenium Test Script – Automation Testing Script With Selenium



First Selenium Test Script – Automation Testing Script With Selenium

Now You will utilize the Mercury Tours websites as your website applications under testing. It is the flight reservation system online that includes all the objects whatever you require for available tutorial.

Create a Script by Recording

Now Let us develop the first testing script on Selenium IDE utilizing the most common way – by just recording the steps. Afterward, we shall run our scripts utilizing the playback features.
Step 1
    • Launching the Firefox & Selenium IDE.
    • Now Type the values for this Base URL: myreservation.demo-site.com
    • Command the Record button on, if it isn't yet pressed by default.
Step 2
From Firefox, navigate the myreservation.demo-site.com. Firefox should carry us on required pages .

Step 3
    • Right click on the blank space with in the pages, like Mercury Tours logo on the top left corners. This will carry the context menu of Selenium IDE. Note: Don't click on any objects or images which is hyperlinked.
    • Choose the Option “Show Available Commands”.
    • Then, choose the “assertTitle exact : Welcome : Mercury Tours”. This is the command that develop the sure that the pages title are perfect.

      First Selenium Test Script
      First Selenium Test Script

Step 4
    • From “User Name” Mercury Tours text box, input the invalid username, “invalidUsN”.
    • From “Password” text box, input the invalid password, “invalidPsW”.
Step 5
    • Now Click on “Sign-In” buttons. Firefox should carry us to available pages.
Step 6
  • To stop recording Just Press the record button off .
Step 7
  • Now that you are completed with our test script, we shall save it in the available test cases. From the File menu, choose the “Save Test Case”. Alternatively, we can easily press Ctrl + S .
Step 8
    • Select the expected location, and then give name to test case like “Invalid__login”.
    • Now Press button “Save”.
Step 9.
  • Need to Notice that the file was stored in the extension of HTML.
Step 10.
  • Now need to Go back to Selenium IDE and press Playback button to run the the complete script. Selenium IDE should be capable to retroflex flawlessly everything.
Introduction to Selenium Commands – Selenese
    • Selenese command can have up to the max of two parameters: value & target.
    • Parameters aren't mandatory all time. It depends on how galore commands will require.
    • For the absolute reference of Selenese command

3 Types of Commands

Actions
Such commands that direct interact with the elements of pages.
For an Example: The “click” commands are action because we direct interact with elements we are clicking at.
The command “type” is also an action because we are setting the values into the text box, and the text box display them to us in return. There is the two way interactions between us and text-box.
Accessors
These are the commands that permit us to save the value to a variables.
For an Example: the “storeTitle” commands are an accessor because it “reads” only the title of page and store it in the variables. It doesn't interact with any elements on the pages.
Assertions
Following are the commands that confirm if definite condition are met...
Assertions have following 3 Types
  • Assert. When any commands fail related to “assert”, immediately testing will stopped.
  • Verify. As soon as “verify” commands get fails, Selenium IDE logs such type of failure and will remain continues with the test running.
  • WaitFor. Before moving ahead to the further command, “waitFor” commands will first delay for the definite conditions to happen true.
    • If conditions becomes true within the period of waiting, the step will pass.
    • If the conditions doesn't become true, the steps will fails. Failure is logged, and the test executions will proceed to the further commands.
    • Default, timeout value always 30 seconds. We can alter this in Selenium IDE Option dialogue from the General tab.

Assert vs. Verify

Common Commands

Command
Number of Parameters
Description
open
0 - 2
With the help of UR, it Opens page.
click/clickAndWait
1
Specified element need to clicked
type/typeKeys
2
Types the characters sequence.
verifyTitle/assertTitle
1
Compare the existent title of page with the expected values.
verifyTextPresent
1
Tests if the definite text is found with in the pages.
verifyElementPresent
1
Tests the existence of a definite elements.
verifyTable
2
Need to Compares the table contents with expected value.
waitForPageToLoad
1
Executions need to Pauses until the pages are loaded properly.
waitForElementPresent
1
Execution need to Pauses until the nominated elements becomes available.

Creating the Script Manually using Firebug

First, we shall develop the similar test cases manually, by writtng the command. This time, we will require to utilize the Firebug.
Step 1
    • Open Selenium IDE after the Firefox.
    • Now Type base URL (mytest.demoaut.com/).
    • Currently record button should be OFF.
Step 2
  • Now Click on the top most blank line from Editor.
  • Just Type the “open” from the Commands text box and hit the Enter.
Step 3
    • Need Navigation in Firefox to our base URL and enable the Firebug
    • From Selenium IDE Editors pane, choose the 2nd line (the lines below are “open” commands) and develop the 2nd command by writing the “assertTitle” on the Commands box.
    • Autocomplete feature can be used freequently.
Step 4

    • From the Firebug, spread out the <head> tag to show the <title> tag.
    • Now Click on the worth of the <title> tags (which is “Welcome: Mercury Tours”) and paste it on to the aim fields in Editor.
Step 5
    • To develop the third commands, click on the 3rd blank line from Editor and key in “type” on the Commands text box.
    • From the Firebug, click on the button of “Inspect”.
Step 6

Need to Notice that the Username text box doesn't have an ID, but it has the attribute NAME . We shall, therefore, utilize the NAME as for locator. Now just Copy values of NAME and paste it onto aim fields available under Selenium IDE.



No comments:

Post a Comment

Popular Posts