【发布时间】:2014-01-12 08:42:42
【问题描述】:
我正在尝试使用 selenium webdriver 来自动化我的测试 我正在使用 selenium 2.39.0 和 firefox 26.0 我正在尝试一个简单的点击示例,但它失败了 该元素被选中是因为所选元素文本上的 sysout 给出了“创建帐户”。但它无法单击按钮
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 组的回复,这很有效
请打开系统显示设置,确保字体大小设置为 100%,见附件截图。 https://code.google.com/p/selenium/issues/detail?id=6756
【问题讨论】:
-
pt-createaccount不是链接,而是li。我可以想象这可能是 Selenium 的问题。你试过用driver.findElement(By.linkText("Create account")).click();吗?