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();                              }             }

1 comment:

  1. Very true my friend, Selenium has evolved the automation world.
    Thanks a lot for taking a time to share the great article.

    Best Selenium training in Chennai | Best Selenium training in Chennai

    ReplyDelete