1

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

1 Answer 1

2

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"));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.