java - 如何获取在selenium中返回 boolean 值的属性值

标签 java selenium attributes

<h1 class="style-scope group-search" data-group-search="false" style="display: none;">Searching...</h1>

我需要使用 selenium-java 获取从 false 变为 true 的值,因此我可以创建一个 preconditionWait 来等待该值返回 true,以便继续该方法。

最佳答案

由于缺乏 HTML 和上下文,很难为您找到可行的解决方案,但这是我最好的..

bool groupSearch = false;
while (!groupSearch)
    groupSearch = Boolean.parse(driver.findElement(By.cssSelector(".style-scope.group-search")).getAttribute("data-group-search"));

// at this point in the code, the `data-group-search` will be `true`

关于java - 如何获取在selenium中返回 boolean 值的属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31735290/

相关文章:

java - selenium XPATH 匹配方法

javascript - 在搜索框中输入文本,然后选择使用 Selenium 和 Python 自动完成

css - 如何将 "add details"转换为 CSS(例如框阴影)

java - j2html保存HTML文件在哪里?

java - 使用奇怪的泛型覆盖 java 方法中的错误

python - 如何在 python 和 selenium 中禁用 chrome 通知弹出窗口?

javascript - 从 PHP 使用 JavaScript 更改 HTML 属性

python - 为类中的所有属性动态创建 @attribute.setter 方法 (Python)

java - 将 TreePath 转换为 JTree

java - 使用对象创建模拟列表