2015-01-10 22 views
0

環境 鉻:39.0.2171.95版本 Chrome的驅動程序:2.13(最新) 硒的webdrivercom.thoughtworks.selenium.SeleniumException:未知的錯誤:元素是不能點擊

我需要在文本框,然後輸入鍵點擊輸入按鈕。腳本在IE和FF中正常工作。但是當涉及到鉻時,我發現一個錯誤

com.thoughtworks.selenium.SeleniumException:未知錯誤:元素在點(221,191)處不可點擊。其他元素將收到點擊:

一些解決方案,我所看見的是使用

((JavascriptExecutor)驅動程序).executeScript( 「window.scrollTo(0,\」 + elementToClick.getLocation()Y + \」 )「);

但它爲我工作。 在此先感謝

回答

0

嘗試等待元素可以點擊,然後點擊它。

您可以使用爲下面的代碼:

//Wait for 20 seconds to detect that the element is clickable, and then clicking on it 
try{ 
    WebDriverWait wait = new WebDriverWait(driver, 20); 
    WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//xpath of the Enter button"))); 
    element.click(); 
}catch(Throwable e){ 
    System.err.println("Error while waiting for the element to be clickable: "+e.getMessage()); 
} 
相關問題