Showing posts with label selenium-2. Show all posts
Showing posts with label selenium-2. Show all posts

Saturday, January 29, 2011

Program to login into a webpage using selenium Webdriver

Login into a page with username text box having id as loginid,password id as password and button id as button.

import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class Login {      public static void main(String[] args) throws Exception {                WebDriver driver = new FirefoxDriver();             driver.get("http://");             WebElement id = driver.findElement(By.id("loginID"));             WebElement pass = driver.findElement(By.id("password"));             WebElement button = driver.findElement(By.id("Button"));                         id.sendKeys("Cheese");             pass.sendKeys("password");             button.click();                              }             }