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

Andrew Newdigate
6,2253 gold badges40 silver badges32 bronze badges
asked Nov 2, 2011 at 7:44

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"));
answered Nov 2, 2011 at 11:56
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.