简体   繁体   English

Selenium ExpectedConditions NOT elementToBeClickable

[英]Selenium ExpectedConditions NOT elementToBeClickable

Working in Java, with an entry-level knowledge. 在Java中工作,具有入门级知识。 We are in the process of moving to Selenium 3, and I was told WebDriverWait needs to use ExpectedConditions, using other methods could lead to having to redo it after the upgrade. 我们正在迁移到Selenium 3,我被告知WebDriverWait需要使用ExpectedConditions,使用其他方法可能导致在升级后必须重做它。 Not sure about this, but I'm going to follow orders here. 不确定这一点,但我会在这里遵循命令。

I'm trying to get rid of a hard wait in an automation spec. 我正试图摆脱自动化规范中的艰难等待。 I'm trying to setup a wait to make sure an element becomes unclickable. 我正在尝试设置等待以确保元素变得不可点击。 More or less trying to do the opposite of 或多或少地试图做相反的事情

WebDriverWait(driver, Timeout.SHORT)
    .until(ExpectedConditions.elementToBeClickable(By.id(elementID)));

There was a single post on SO that referenced this. SO上有一篇文章引用了这一点。 I tried to implement their answer, but alas it did not work. 我试图实现他们的答案,但唉它没有用。 That answer can be found here: How to wait for an element NOT to be clickable using Selenium Webdriver? 这个答案可以在这里找到: 如何使用Selenium Webdriver等待元素不可点击?

I was getting some errors on top of some issues related to the use of Predicate class. 我在使用Predicate类的一些问题上遇到了一些错误。

Any and all help/suggestions would be greatly appreciated. 任何和所有的帮助/建议将不胜感激。

The ExpectedConditions of Selenium come with ExpectedConditions.not() which should be exactly what you are asking for (link to documentation ). Selenium的ExpectedConditions带有ExpectedConditions.not() ,这应该是你要求的(链接到文档 )。

WebDriverWait(driver, Timeout.SHORT)
    .until(ExpectedConditions.not(
        ExpectedConditions.elementToBeClickable(By.id(elementID)))
    );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 wait.until(ExpectedConditions.elementToBeClickable)不工作 - wait.until(ExpectedConditions.elementToBeClickable) not working Selenium + Java 的 elementToBeClickable 问题 - elementToBeClickable issues with Selenium + Java wait.until(ExpectedConditions.elementToBeClickable)没有等待定义的时间 - wait.until(ExpectedConditions.elementToBeClickable) is not waiting for the defined time 错误:ExpectedConditions 类型中的 elementToBeClickable(By) 方法不适用于参数 (WebElement) - Error:The method elementToBeClickable(By) in the type ExpectedConditions is not applicable for the arguments (WebElement) 如何在 Selenium 4 中使用 ExpectedConditions? - How to use ExpectedConditions in Selenium 4? Selenium 3.0 ExpectedConditions问题 - Selenium 3.0 ExpectedConditions issue 即使在满足 ExpectedConditions.elementToBeClickable 和visibilityOfElementLocated 条件后,元素不可交互异常也会抛出 - Element not interactable exception is thrown even after ExpectedConditions.elementToBeClickable and visibilityOfElementLocated conditions fulfilled WebDriver Wait'.until(ExpectedConditions.elementToBeClickable'仅在我将Thread.sleep(500)添加到代码时才有效? - WebDriver Wait '.until(ExpectedConditions.elementToBeClickable' only works when i add Thread.sleep(500) to the Code? Selenium更新后,ExpectedConditions将不起作用 - ExpectedConditions won't work after Selenium update 如果有多个具有相同xpath的元素,“ wait.until(ExpectedConditions.elementToBeClickable(By.xpath()))”会做什么? - what does “wait.until(ExpectedConditions.elementToBeClickable(By.xpath()))” do if there are more than one element with the same xpath?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM