i'm new to selenium 2.0. i'm not able to find which code we to use to click on particular link in case of webdriver..
WebDriver driver = new FirefoxDriver();
driver.get("url");
WebElement element = driver.findElement(By.name("UserName"));
``WebElement element1=driver.findElement(By.id("password"));
now i need to click on signIn button after sometime signOut
which code i need to use to perform the above operation
Andrew Newdigate
6,2253 gold badges40 silver badges32 bronze badges
1 Answer 1
I presume the element you want to click is a <button>
. Presuming the button has the class "signin", you could click it using the following snippet.
WebDriver driver = new FirefoxDriver();
driver.get(baseUrl + "/");
WebElement signinButton = driver.findElement(By.cssSelector("button.signin"));
signinButton.click();
If the button has an id instead of a class, you could use this instead
WebElement signinButton = driver.findElement(By.id("buttonId"));
answered Nov 2, 2011 at 11:56
Sign up to request clarification or add additional context in comments.
Comments
lang-java