2017-06-15 63 views
0

我想明確地等待,直到我的元素啓用點擊屏幕。 但是目前發生的是元素是可見的,但由於加載符號驅動程序無法點擊元素&代碼失敗。如果我使用暗指等待,然後代碼工作。任何建議如何檢查元素是否準備點擊

WebDriverWait wait1 = new WebDriverWait(driver, new TimeSpan(0,0,60)); 
wait1.Until(ExpectedConditions.ElementSelectionStateToBe(By.XPath(GPDNav),true)); 
// wait1.Until(ExpectedConditions.ElementIsVisible(By.XPath(GPDNav))); 
IWebElement gpdNav = driver.FindElement(By.XPath(GPDNav)); 
gpdNav.Click(); 
+0

在預期的情況下,我們會像elementtobeclickable ...你能檢查嗎? –

+0

不工作太..已嘗試.. –

+0

var wait = new WebDriverWait(driver,TimeSpan.FromMinutes(1)); var clickableElement = wait.Until(ExpectedConditions.ElementIsClickable(By.Id(「id」))); –

回答

0

您必須等待加載元素消失。找到加載元素的xpath並將其放置在下面的代碼中並嘗試。在我們的應用程序中我們有相同類型的加載符號,並且在等待加載元素的不可見性後它工作正常。

WebDriverWait wait1 = new WebDriverWait(driver, new TimeSpan(0,0,60)); 
wait1.until(ExpectedConditions.InvisibilityOfElementLocated(By.xpath("xpath of loading symbol")); 
wait1.Until(ExpectedConditions.ElementSelectionStateToBe(By.XPath(GPDNav),true)); 
// wait1.Until(ExpectedConditions.ElementIsVisible(By.XPath(GPDNav))); 
IWebElement gpdNav = driver.FindElement(By.XPath(GPDNav)); 
gpdNav.Click(); 
0

嘗試使用兩個明確的等待,第一個等到「裝載」符號消失,第二個要等到「按鈕」是可以點擊的。

WebDriverWait wait = new WebDriverWait(driver, 30); 
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//*[loading]"))); 
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[button]")));