Sunday, November 27, 2016

Validating conditions using assert and verify in Selenium IDE

The purpose of any automation/manual tests is to validate the application is working correctly and validating the actual outcome with the expected outcome for a condition.


  • Now the first question arises, what are the commands in selenium IDE which validates the outcome of condition There are different commands in different tools/automated suite. In selenium IDE, we can use assert or verify commands to validate the results.
  • Now the question two arises, what is the difference between assert and verify commands, When we use Assert command, it checks whether the given condition is true or false and stops further test execution if the assert statement fails. In case of verify command, in case the execution fails, the execution moves to next step in the test although the test is marked as failed.
  • Now coming to question three, when to use verify or assert command. In case of critical condition failing and no point to continue with test, use assert command. In case of minor condition failing in the test and we still wants to continue with further steps in the test, we can use verify statement.
  • So what is the next logical question in mind, when and how  to add the validation steps in test.Since Selenium IDE is a record and play tool,
    • Record execution flow. Once execution flow is recorded, we can add assertions in Selenium IDE.
    • Just right click the element on which the condition needs to be verified in Firefox browser e.g : Validating the text of the link. 
    • Click on the assertion to be added as shown below:

Add assertions selenium IDE


Similar to assert/verify commands in selenium IDE, we can use assert and soft.assert class for assert and verify command in Selenium Webdriver.

How to run test with random data in Selenium IDE: store and storeText Command

Selenium IDE is a tool for record and play functionality, which runs the script with same set of data, however we can generate random data. store the values in a variable , and use the value stored in the variable in the later steps in the test.


Expected Learning from this article:

  • Store command to store random generated data in the a variable. 
  • Using the stored information in later steps in the test.
  • Using command storeText to store value of an object in the test and storing in a test.
  • Using the stored information in later stage in the test.



Below screenshot shows how to use store and storetext in the test:




  • In the above test, we open an application and save the text of the link in variable using command storeText. test in Value is the variable in each we can store the value of the link/object.
  • In the next step, we can use the value in the variable using ${variable_name} which is ${test} in our example.
  • Similarly using store command and javascript, we can generate random data, store in the variable and use further in the test.
  • We have saved the test in an html file and the test file looks as below:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="https://www.google.co.in/" />
<title>testing stored value</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">testing stored value</td></tr>
</thead><tbody>
<tr>
 <td>open</td>
 <td>/search?q=selenium&amp;ie=utf-8&amp;oe=utf-8&amp;client=firefox-b-ab&amp;gfe_rd=cr&amp;ei=r4E6WIqnEeXI8AfOn6awBw</td>
 <td></td>
</tr>
<tr>
 <td>storeText</td>
 <td>link=Selenium - Web Browser Automation</td>
 <td>test</td>
</tr>
<tr>
 <td>type</td>
 <td>id=lst-ib</td>
 <td>${test}</td>
</tr>
<tr>
 <td>click</td>
 <td>name=btnG</td>
 <td></td>
</tr>
<tr>
 <td>store</td>
 <td>javascript{&quot;Selenium&quot; +Math.random();}</td>
 <td>testrandom</td>
</tr>
<tr>
 <td>type</td>
 <td>id=lst-ib</td>
 <td>${testrandom}</td>
</tr>
<tr>
 <td>click</td>
 <td>name=btnG</td>
 <td></td>
</tr>

</tbody></table>
</body>
</html>

Copy paste the code in a text file and save in html format. Open the test in Selenium Ide and try to run the test and understand how to run test with random data in selenium IDE.

Tuesday, November 22, 2016

Tutorials for Selenium IDE easy understanding


Selenium IDE :: Add-ons for Firefox - Download Selenium IDE from the link for
firefox. Remember Selenium IDE is add-on for firefox browser only.

Download Selenium IDE - Official site for Selenium. Can learn about selenium
IDE and release notes from this page.

Introduction to Selenium IDE - Guru99 - Excellent link to start understanding about Selenium IDE

Introduction to Selenium IDE (Installation and its Features) - Another interesting blog to understand the concept of Selenium IDE.

Useful tutorial Posts for Selenium IDE in this blog:


Mindmap for understanding Selenium IDE - Mindmap to understand what selenium IDE is all about. 

Installing Selenium IDE add-on in firefox - How to install Selenium IDE add-on in firefox.

Understanding and locating Locators in Selenium IDE - What are locators in Selenium IDE and how are locators used to identify an element in Selenium IDE

Log file for Selenium IDE execution using FileLogging addon for firefox - Log file are useful to identify failures in execution and validating the performance of application response.This article explains how to create log file for execution in Selenium IDE

Selenium Commands in Selenium IDE - This article explains what are the selenese commands most commonly used in Selenium IDE

Exporting selenium IDE tests to WebDriver - Test recorded using Selenium IDE can be imported into different languages support. This article explains how to export selenium IDE tests to Selenium WebDriver.

Selenium IDE Panes and Shortcut keys - This article explains the Interface of Selenium IDE with details of different panes and shortkeys for operations in Selenium IDE.

How to run test with random data in Selenium IDE: store and storeText Command - This article explains how to store information in application or using javascript, generating random data and storing in a variable.



Validating conditions using assert and verify in Selenium IDE -This post explains how to add assertions in Selenium IDE and what is the difference between assert and verify statement.

Friends, there may be many interesting blogs/post for Selenium IDE, which you have come across. Please feel free to ion share such links as can be useful for other readers.