7g. Selenium IDE – Recording and running a test case

Hiya testers! Welcome to another explore-along post in the land of Magic Meadows. Follow closely and work along to see some real magic happening when we playback our recordings.

We will be creating our first test script in Selenium IDE by recording and executing the same with the help of the playback feature.

Scenario:

  • Open Gmail login page
  • Enter any invalid username and password
  • Submit the details for login
  • Assert the error message displayed due to the submission of invalid credentials
  • Assert the title of the page
  • Insert a new command to wait for a particular value
  • Verify the logs from Selenium IDE tool
  • Save the test case in desired location

Step 1:

  • Launch Firefox browser and Selenium IDE tool
  • By default the record button will be in ON state
  • Enter the URL value “https://accounts.google.com/” in the Base URL text bar

Base URL
Step 2:

  • Navigate to “https://accounts.google.com/” in Firefox browser
  • Make sure the record button is in ON state, otherwise toggle to turn it on
  • Enter any invalid username and click “Next”
  • Enter any invalid password. At this moment, Selenium IDE editor section will look like this,Step2_Credentials

Step 3:

  • Click on “Sign In” button
  • Error message will be displayed
  • To verify the message, select it and right click
  • This opens the Selenium IDE context menu
  • To see all the commands, click on “Show Available Commands”
  • Select “assertText id=errormsg_0_Passwd The email and password you entered don’t match.”Verify text command

Step 4:

  • Right click anywhere on the page except hyperlinks and images
  • Select “Assert Title Gmail” to verify the page title

Assert title Gmail

  • Toggle the record button to change it to OFF state
  • Completed script will look as shown below

Test Script
Step 5:

  • Let us insert a new command before entering the password
  • In Selenium IDE, on the command ‘type’ with target as ‘id=Passwd’, right click and select “Insert New Command”

Insert new command

  • In the Command, Target, Value section enter ‘waitForValue’ for command and ‘id=Passwd’ for target

Step 6:

  • For playback, click on ‘Play current test case’ icon as shown below,

Playback

  • Check if the scenario gets replicated flawlessly
  • Each step will be coded in green as it gets executed successfully
  • Logs can be viewed and the logging level can be chosen as per our need

Test passed

  • In case the test case fails, error will be shown in logs coded in red color

Error log
Step 7:

  • Once we are satisfied with the result, we would like to save this test case for future purposes such as, regression testing
  • Click on File menu and select ‘Save Test Case’

Save test case

  • Enter the File name in the pop up window and click on ‘Save’

File name and save

  • The saved file will in HTML format by default

Saved file
Now it’s your turn to try new scenarios. Once recorded, sit back, relax and watch Selenium IDE do the testing for you.

Have a great day!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.