Reputation: 81
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
Upvotes: 1
Views: 534
Reputation: 6225
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"));
Upvotes: 2