1

I am trying to use the selenium webdriver to automate my testing I am using selenium 2.39.0 and firefox 26.0 I am tryign a simple example example for a click but its failing The element is selected because a sysout on the selected element text gives "create account".But its not able to click the button

 WebDriver driver = new FirefoxDriver();
driver.get("http://en.wikipedia.org/wiki/Main_Page");
System.out.println(driver.findElement(By.id("pt-createaccount")).getText());
driver.findElement(By.id("pt-createaccount")).click();
assertEquals("Create account - Wikipedia, the free encyclopedia", driver.getTitle());
driver.quit();

Any help is appreciated

Tried all the below things Got a reply from the selenium google group and this worked

Please open the system display settings and ensure that font size is set to 100%, see the attached screenshot. https://code.google.com/p/selenium/issues/detail?id=6756

Curious
2824 silver badges21 bronze badges
asked Dec 24, 2013 at 5:18
1
  • pt-createaccount is not a link but a li. I can imagine that it could be the problem for Selenium. Have you tried to use driver.findElement(By.linkText("Create account")).click(); ? Commented Dec 24, 2013 at 5:57

2 Answers 2

1

You need to click on "a" element:

IWebElement createAccountLink = driver.findElement(By.id("pt-createaccount")).FindElement(By.TagName("a")); 
createAccountLink.Click();
answered Dec 24, 2013 at 8:09
Sign up to request clarification or add additional context in comments.

Comments

0
public class Wiki
{
 @Test
 public void createAccount() throws InterruptedException
 {
 WebDriver driver = new FirefoxDriver();
 WebDriverWait wait=new WebDriverWait(driver,60);
 driver.get("http://en.wikipedia.org/wiki/Main_Page");
 driver.findElement(By.linkText("Create account")).click();
 wait.until(ExpectedConditions.titleContains("Create account - Wikipedia, the free encyclopedia"));
 Assert.assertEquals("Create account - Wikipedia, the free encyclopedia",driver.getTitle());
 driver.quit();
 }
}
Farvardin
5,4226 gold badges36 silver badges54 bronze badges
answered Dec 24, 2013 at 8:27

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.