×

First test case of Selenium-IDE

First Test Case of Selenium-IDE:

In this part, we are discussing how to create a basic test case in Selenium-IDE:

The entire test script execution process in Selenium -IDE can be divided into the following steps:

  • Recording (record the user interactions with the browser)
  • Playing back (executing the recorded script)
  • Save the test case suite
  • Export the test script

Now, we will look into the implementation of the above three steps.

Recording:

  • Launch the Firefox browser.
  • Click on the Selenium icon, which was present on the top right corner of the Firefox browser.
  • The browser will launch the default interface of Selenium-IDE, and asking you to create a project.
default interface of Selenium-IDE
  • Give a project name, e.g., first_test_case
  • Give a test name, e.g.-tutorialandexample_test.
Give a test name
  • Click on the Start Recording Button, which is present at the top right corner on the Selenium-IDE interface.
Start Recording Button
  • After click on the start recording button, one pop-up window will be shown where you have to give a base URL. e.g., https://www.google.com/ and again click on the start recording button.
one pop-up window will be shown
  • It will redirect you to the Google search page, where you can type tutorial and example.com and click on the first link.
you can type tutorial and example.com and click on the first link
  • It will redirect to the home page of tutorial and examples .com.
  • Go to selenium –IDE and click on the stop recording button, it will stop your action with browser immediately. 
  • And the text editor box has recorded all the action performs on the browser.
text editor box has recorded all the action

Now, we are going to the next step, which includes executing the recorded script.

Playing Back:

  • Click on Run Current test button, which is present on the toolbar menu of the Selenium-IDE.
  • It will execute all the interactions with the browser and gives you an overall summary of the completed test scripts.
  • Executed test scripts summary will be displayed on the log pane.
Executed test scripts summary

Now, we are coming to our next segment, where we can learn about how we can save the project.

Save Project:

  • Click on the save project button present on the extreme right corner of the menu bar.
  • Save the test case suite as First_Test_case.
Save the test case suite as First_Test_case
  • The test case suite can be found at the location provided in the above steps. Notice that the test script saved as .side format.
test case suite can be found at the location

Export Test Script

There is no export option in the latest version of Selenium IDE because there is no file menu present in the IDE interface.

 But it is available in the test suit box which is shown in the below snapshot:

latest version of Selenium IDE

To export our test case in different languages in selenium ide, follow below steps:

For our better understating that how we export our test script in a different language, we are considering the above example

  • First right click on the existing test case tutorialandexample_test and click on the export button.
selenium ide first test case
  • After click on the export button, one pop-up window will be opened and ask you to select one of the programming languages.
  • Select one of the options and click on the export button.
Select one of the options and click on the export button
  • Export your test case file in your local system and save it with a particular name.
Export your test case file in your local system
  • After saving the exported file in our local system, we will open that file. You can open that exported file, go to your Selenium IDE interface and click on the particular file.
After saving the exported file in our local system
  • When we click on the saved file, one pop-up window will appear and ask you to open your file in a different text editor.
  • Select one of the text editors and click on the ok button.
Select one of the text editors and click on the ok button
  • Your test script will look like this in java language.
// Generated by Selenium IDE
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is; 
import static org.hamcrest.core.IsNot.not;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Alert;
import org.openqa.selenium.Keys; 
import java.util.*;
public class TutorialandexampletestTest {
 private WebDriver driver;
 private Map vars;
 JavascriptExecutor js;
 @Before
 public void setUp() {
 driver = new ChromeDriver(); 
 js = (JavascriptExecutor) driver;
 vars = new HashMap();
 }
 @After
 public void tearDown() {
 driver.quit(); 
 }
 @Test
 public void tutorialandexampletest() {
 driver.get("https://www.google.com/");
 driver.manage().window().setSize(new Dimension(1287, 728));
 driver.findElement(By.name("q")).sendKeys(Keys.DOWN);
 driver.findElement(By.name("q")).sendKeys("tutorial and example .com");
 driver.findElement(By.name("q")).sendKeys(Keys.ENTER);
 { 
 WebElement element = driver.findElement(By.cssSelector("div:nth-child(2) > .rc .iUh30"));
 Action builder = new Actions(driver);
 builder.moveToElement(element).perform();
 }
 {
 WebElement element = driver.findElement(By.tagName("body")); 
 Action builder = new Actions(driver);
 builder.moveToElement(element, 0, 0).perform();
 }
 driver.findElement(By.linkText("CCNA Tutorial")).click();
 driver.findElement(By.cssSelector("div:nth-child(2) > .rc .ellip")).click();
 }
} 

Related Topics

CSS Selector: Inner text in Selenium IDE

CSS Selector: Inner text The inner text is used to identify and create a CSS Selector using a string pattern of the HTML tag which is displayed on the web page. Syntax...

1 minute read.

Selenium WebDriver-XPath Locator

Selenium WebDriver-XPath Locator The locators can make the object identification of all the selenium tools. There are eight locators available in selenium web driver, but most of the time we go for...

14 minutes read.

CSS Selector: Class in selenium IDE

CSS Selector: Class Identify a web element with the help of Class as a CSS Selector is like using id attribute. The only difference between Class and id is in their...

2 minutes read.

Selenium WebDriver-CSS Selector: Tag Class and Attribute

Selenium WebDriver-CSS Selector: Tag, Class, and Attribute We will locate the web element with the help of Tag, class, and attribute CSS selector locator in this section of the tutorial. Where Tag,...

5 minutes read.

First test case of Selenium-IDE

First Test Case of Selenium-IDE: In this part, we are discussing how to create a basic test case in Selenium-IDE: The entire test script execution process in Selenium -IDE can be divided...

4 minutes read.

Selenium WebDriver - IE [Internet Explorer] browser

Selenium WebDriver - IE [Internet Explorer] browser In this segment, we will understand how to run a test script with the help of the IE (Internet Explorer) browser. It is a standalone...

4 minutes read.

Drag and Drop Event Handling

Drag and Drop Event Handling: In this tutorial, we will learn how to handle the drag and drop event in selenium WebDriver using the action class. Before going further in this tutorial...

6 minutes read.

Selenium Wait

In this tutorial, we will understand how we can avoid synchronization issues while executing the test script in a selenium WebDriver. Before going further in this tutorial, first, we will understand that...

10 minutes read.

Selenium WebDriver-Alert Popup

Selenium WebDriver-Alert Popup  An alert popup is one of the small message boxes, which used to give some information to the user that displays on the browser. The Alert popup will be...

6 minutes read.

WebDriver-Tag Name Locator

Selenium WebDriver-Tag Name Locator The tag name locator is used along with the findElements() method to identify multiple similar elements in the UI. It is used to locate the web element with...

3 minutes read.

Link Text Locator in Selenium IDE

LINK TEXT Link textlocator is used to identify only the weblink element based on the name of the link. Whenever multiple links are there, it will not work; it will work only...

1 minute read.

Selenium vs QTP

In this section, we are comparing the most frequently used automation tool –Selenium and QTP. Selenium and QTP have relative advantages over each other- FeaturesSeleniumHP QTPLicensingSelenium is an open-source testing tool....

3 minutes read.

Selenium IDE Commands

Selenium –IDE Commands (SELENESE): Selenese commands are the set of commands used in Selenium IDE. Selenese command has two parameters target and value. Selenese command tests the existence of UI elements based on their HTML tags,...

3 minutes read.

CSS Selector: ID/Class and Attribute in Selenium IDE

CSS SELECTOR: ID/Class and Attribute The Id, class, and attribute of CSS selector are used to identify the web element to access the web pages.  Syntax for Id/Class and Attribute: css= <./#> {[attribute=Value of...

2 minutes read.

Name Locator in Selenium IDE

NAME LOCATOR: It is used to find the name in the web element. If we have multiple web elements of the same name, then the first matched element would be returned. Open the...

3 minutes read.

Selenium WebDriver Tutorial

Seleniun WebDriver Introduction Selenium WebDriver is the essential tool of Selenium Tool Suite because it can directly communicate the browser without any server.  Selenium WebDriver is a browser automation framework that accepts...

3 minutes read.

Id Locator in Selenium IDE

Id Locator Id locator is used to find the web element by the help of id of that element because ID is likely to be unique for each web element. Target Format: Id=id of the...

2 minutes read.

Operational Controls Methods in Selenium WebDriver

Operational Controls Methods The Operational controls are used to perform all the actions on the web elements like click on the button, pass the value in the text box, and click...

4 minutes read.

Selenium WebDriver- Radio button handling

Selenium WebDriver- Radio button handling In this tutorial, we will be learning about handling the radio button in selenium WebDriver. Let us take one example to give you a better understanding of...

3 minutes read.

Selenium Assertion

Selenium Assertion: In this section, we will learn about the Assertion in Selenium WebDriver. An Assertion is a feature available in TestNG, which is used to verify the expected result of...

7 minutes read.