![](/img/trans.png)
[英]Click() action is not working with firefox in selenium webdriver
[英]Selenium Webdriver click not working
我正在嘗試使用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();
任何幫助表示贊賞
嘗試了以下所有操作從硒谷歌集團獲得回復
請打開系統顯示設置,並確保將字體大小設置為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();
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();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.