HOW TO RUN THE SCRIPT USING SELENIUN IDE?

Follow the following steps to run a script using selenium IDE:
  • Open Firefox browser.
  • Open selenium IDE from Tools in browser.
  • Verify the RECORD button is ON in selenium IDE window.
  • Search “selenium ide” in Google.
  • Verify the recorded script in selenium IDE window.
  •  Command      
     Target     
     Value             
     open
    /
     type
    id=gbqfq
    Hello Selenium
    click
    id=gbqfb

    * Base URL: 
    http://www.google.co.in/
    
  • Run the recorded script.

HTML Source code:

RunScriptUsingSeleniumIDE
open http://www.google.co.in/
type id=gbqfq Hello Selenium
click id=gbqfb


Java Source code:

package com.helloselenium.tests;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

public class RunScriptUsingSeleniumIDE{

  public static void main(String args[]) {

    String baseUrl = "http://www.google.co.in/";

    WebDriver driver = new FirefoxDriver();    
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    driver.get(baseUrl + "");
    driver.findElement(By.id("gbqfq")).clear();
    driver.findElement(By.id("gbqfq")).sendKeys("Hello Selenium");
    driver.findElement(By.id("gbqfb")).click();

    driver.quit();
  }
}

JUnit Source code:

package com.helloselenium.tests;

import org.junit.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

public class RunScriptUsingSeleniumIDE{
  private WebDriver driver;
  private String baseUrl;

  @Before
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://www.google.co.in/";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test
  public void testUntitled() throws Exception {
    driver.get(baseUrl + "");
    driver.findElement(By.id("gbqfq")).clear();
    driver.findElement(By.id("gbqfq")).sendKeys("Hello Selenium");
    driver.findElement(By.id("gbqfb")).click();
  }

  @After
  public void tearDown() throws Exception {
    driver.quit();
  }
}

TestNG Source code:

package com.helloselenium.tests;

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

public class RunScriptUsingSeleniumIDE{
  private WebDriver driver;
  private String baseUrl;

  @BeforeTest
  public void setUp() throws Exception {
    driver = new FirefoxDriver();
    baseUrl = "http://www.google.co.in/";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  }

  @Test
  public void testUntitled() throws Exception {
    driver.get(baseUrl + "");
    driver.findElement(By.id("gbqfq")).clear();
    driver.findElement(By.id("gbqfq")).sendKeys("Hello Selenium");
    driver.findElement(By.id("gbqfb")).click();
  }

  @AfterTest
  public void tearDown() throws Exception {
    driver.quit();
  }
}

For other source code contact to us.


Post a Comment

0 Comments