In this article, we are going to learn how to record steps in selenium IDE. We are going to see some basic path as well as some basic command descriptions.
Step 1 : Please Install IDE & Firefox (for reference you may see one of my previous posts)
Step 2 : Start Firefox
Step 3 : From menu, click tools, and then select Selenium IDE
Step 4 : By default, when IDE opened, it is recording mode( like , it is recording). In the example I am using www.kaz.com.bd this site for practice.
Step 4 : now, From browser go to www.kaz.com.bd
Step 5 : You get a static HTML site with 4 tabs “Home”, “Talents”,” Culture”,” Contact”.
Step 6: click on “Home”, then “Talents”,” Culture”,” Contact” accordingly and from stat menu bar, open selenium IDE UI. You will get those 4 steps listed
Step 7: Press stop button from Selenium IDE (right Upper corner Red Round Button)
Now, you have finished recording where steps are simple clicking tabs.
From the IDE, you can work on those steps like re-run.
Now, We will see how to get web driver Unit test codes (Selenium IDE supported some experimental codes)
Step 1 : To get the code, go to Option –> Options… and check the “Enable experimental features” and press ok
Step 2: Now, After recording from IDE, click Options -> Format and get the list below
Step 3: Select c#/NUnit /webDriver ( later on we will also get the JUnit 4 code also) and press OK on warning message( as this is experimental code, so it may be not very accurate).
Now you get the code
In C# Code we have
If we make a JAVA project in Eclipse(see my previous post on how to create webdriver environment setup) and copy to class to a new empty class, we can run the webDriver Unit test case code Running as JUnit 4.0 test project.
For detail about Selenium IDE, you can visit the link
Step 1 : Please Install IDE & Firefox (for reference you may see one of my previous posts)
Step 2 : Start Firefox
Step 3 : From menu, click tools, and then select Selenium IDE
Step 4 : By default, when IDE opened, it is recording mode( like , it is recording). In the example I am using www.kaz.com.bd this site for practice.
Step 4 : now, From browser go to www.kaz.com.bd
Step 5 : You get a static HTML site with 4 tabs “Home”, “Talents”,” Culture”,” Contact”.
Step 6: click on “Home”, then “Talents”,” Culture”,” Contact” accordingly and from stat menu bar, open selenium IDE UI. You will get those 4 steps listed
Step 7: Press stop button from Selenium IDE (right Upper corner Red Round Button)
Now, you have finished recording where steps are simple clicking tabs.
From the IDE, you can work on those steps like re-run.
Now, We will see how to get web driver Unit test codes (Selenium IDE supported some experimental codes)
Step 1 : To get the code, go to Option –> Options… and check the “Enable experimental features” and press ok
Step 2: Now, After recording from IDE, click Options -> Format and get the list below
Step 3: Select c#/NUnit /webDriver ( later on we will also get the JUnit 4 code also) and press OK on warning message( as this is experimental code, so it may be not very accurate).
Now you get the code
In C# Code we have
1: using System;
2: using System.Text;
3: using System.Text.RegularExpressions;
4: using System.Threading;
5: using NUnit.Framework;
6: using OpenQA.Selenium;
7: using OpenQA.Selenium.Firefox;
8: using OpenQA.Selenium.Support.UI;
9:
10: namespace SeleniumTests
11: {
12: [TestFixture]
13: public class Untitled
14: {
15: private IWebDriver driver;
16: private StringBuilder verificationErrors;
17: private string baseURL;
18:
19: [SetUp]
20: public void SetupTest()
21: {
22: driver = new FirefoxDriver();
23: baseURL = "http://www.kaz.com.bd/";
24: verificationErrors = new StringBuilder();
25: }
26:
27: [TearDown]
28: public void TeardownTest()
29: {
30: try
31: {
32: driver.Quit();
33: }
34: catch (Exception)
35: {
36: // Ignore errors if unable to close the browser
37: }
38: Assert.AreEqual("", verificationErrors.ToString());
39: }
40:
41: [Test]
42: public void TheUntitledTest()
43: {
44: driver.Navigate().GoToUrl(baseURL + "/");
45: driver.FindElement(By.LinkText("Home")).Click();
46: driver.FindElement(By.LinkText("Talents")).Click();
47: driver.FindElement(By.LinkText("Culture")).Click();
48: driver.FindElement(By.LinkText("Contact")).Click();
49: }
50: private bool IsElementPresent(By by)
51: {
52: try
53: {
54: driver.FindElement(by);
55: return true;
56: }
57: catch (NoSuchElementException)
58: {
59: return false;
60: }
61: }
62: }
63: }
Step 4 : So, After recording we are getting NUnit code here.
If we make an empty class type project in vs2010(see my previous post on how to create webdriver environment setup) and copy to class to a new empty class, we can run the webDriver Unit test case using NUnit GUI(after building Project)
If we choose the JAVA/JUnit4 webDriver then , we will get the following code
If we make an empty class type project in vs2010(see my previous post on how to create webdriver environment setup) and copy to class to a new empty class, we can run the webDriver Unit test case using NUnit GUI(after building Project)
If we choose the JAVA/JUnit4 webDriver then , we will get the following code
In JAVA code we get
1: package com.example.tests;
2:
3: import com.thoughtworks.selenium.Selenium;
4: import org.openqa.selenium.*;
5: import org.openqa.selenium.htmlunit.*;
6: import org.openqa.selenium.firefox.*;
7: import org.openqa.selenium.chrome.*;
8: import org.openqa.selenium.ie.*;
9: import org.junit.*;
10: import static org.junit.Assert.*;
11:
12: public class Untitled {
13:
14: WebDriver driver;
15: Selenium selenium;
16:
17: @Before
18: public void startSelenium() {
19: driver = new FirefoxDriver();
20: selenium = new WebDriverBackedSelenium(driver, "http://www.kaz.com.bd/");
21: }
22:
23: @After
24: public void stopSelenium() {
25: driver.close();
26: }
27:
28: @Test
29: public void testUntitled() {
30: selenium.open("/");
31: selenium.click("link=Home");
32: selenium.waitForPageToLoad("30000");
33: selenium.click("link=Talents");
34: selenium.waitForPageToLoad("30000");
35: selenium.click("link=Culture");
36: selenium.waitForPageToLoad("30000");
37: selenium.click("link=Contact");
38: selenium.waitForPageToLoad("30000");
39: }
40:
41: }
For detail about Selenium IDE, you can visit the link
Thanks for reading this….:)
This is shantonu's personal blog.Mail[shantonu_oxford@yahoo.com] to contact.