2017-06-15 64 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]")));