Wednesday, February 26, 2014

Opening website in firefox, Searching for word 'trimmer'( in the field) and click button

//here i would like to open "homedepot" website, search for trimmer and
//also i would like to know what all items available in website, such as categories..by hitting links.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.WebElement;

public class Homedepotwebsitetesting {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        WebDriver driver = new FirefoxDriver();
      //WebDriver driver = FirefoxDriver();
        driver.get("http://homedepot.com");
       
        WebElement element1= driver.findElement(By.xpath("//input[@id='searchFocus']")); //finding element- field
        element1.sendKeys("trimmer"); //entering word 'trimmer' on the webelement- search field
       
        driver.findElement(By.xpath("//button[@id='searchButton']")).click(); //find searchbutton and click i
        //WebElement element2 = driver.findElement(By.xpath("//button[@id='searchButton']")); //find searchbutton and click it
       //element2.click();
       
    }

}

No comments:

Post a Comment