我正在尝试使用 selenium webdriver 来自动化我的测试 我使用的是selenium 2.39.0和firefox 26.0 我正在尝试一个简单的点击示例,但失败了 该元素被选择是因为所选元素文本上的系统输出给出“创建帐户”。但它无法单击按钮
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();
感谢任何帮助
尝试了以下所有操作 得到了 selenium google group 的回复,这有效了
请打开系统显示设置并确保字体大小设置为100%,请参阅随附的屏幕截图。 <强> https://code.google.com/p/selenium/issues/detail?id=6756
最佳答案
您需要点击“a”元素:
IWebElement createAccountLink = driver.findElement(By.id("pt-createaccount")).FindElement(By.TagName("a"));
createAccountLink.Click();
关于java - Selenium Webdriver 单击不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20755246/