Favourite Quote

Every artist was first an amateur. - Ralph Waldo Emerson The more difficulties one has to encounter, within and without, the more significant and the higher in inspiration his life will be. - Horace Bushnell

Thursday, March 1, 2012

Writing our first script in WebDriver


Prior to getting started with writing scripts ensure that you have completed your installations & you have identified which framework you would work with

I have chosen to write the test in JUnit Framework , Where Eclipse is my IDE & Selenium 2.

Here is a basic script for search on an amazon site.

Objects that are dealt are :

1. Drop down list

2. Text box

3. Button

4. Link

Actions performed are :

1. Am selecting a value from drop down list

2. Enetering text in the text box

3. Clicking on the button.

4. Clicking the link that meets my partial text of the url's fetched


import org.junit.Test;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

public class Search {

@Test

public void testSearch(){

WebDriver driver = new FirefoxDriver();

driver.navigate().to("http://www.amazon.co.uk/");

WebElement dropDownsearch = driver.findElement(By.id("searchDropdownBox"));

dropDownsearch.sendKeys("Electronics & Photo");

driver.findElement(By.id("twotabsearchtextbox")).clear();

driver.findElement(By.id("twotabsearchtextbox")).sendKeys("Sat Nav & Car Electronics");

driver.findElement(By.id("navGoButton")).click();

driver.findElement(By.partialLinkText("Satellite Navigation System")).click();

driver.close();

}

}
automationwithselenium.blogspot.com-Google pagerank and Worth

2 comments:

  1. Hi Shabana, i need some info abt Jmeter, right now iam working as QA Automation in C london,
    please provide info to contact..
    mails2chandra.v@gmail.com

    ReplyDelete
    Replies
    1. Hey There,

      My Blog has most of the information you are seeking on Jmeter.

      Any specifics please ask

      Delete