【问题标题】:Locating ids with forward slashes使用正斜杠定位 id
【发布时间】:2017-03-20 02:44:35
【问题描述】:

我有以下按钮:

<button id="Organisation/user" class="button-2xhG8" data-reactid=".0.2:$organization.0.0.2:$1/47">org</button>

我正在尝试使用以下命令点击它:

browser.waitForExist("#Organisation/user",10000)
browser.click("#Organisation/user")

无济于事。但以下确实有效:

 browser.waitForExist(".button-2xhG8",10000)
 browser.click(".button-2xhG8")

并且我可以点击其他按钮,而无需用户在其 ID 中使用正斜杠。如何找到按钮?

【问题讨论】:

    标签: javascript selenium css-selectors webdriver webdriver-io


    【解决方案1】:

    您必须对属性中的特殊字符进行双重转义

    browser.waitForExist("#Organisation\\/user",10000)
    

    【讨论】:

      【解决方案2】:

      您可以选择您的按钮,例如button[id='Organisation/user']

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-05-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-10
        • 1970-01-01
        • 2022-11-25
        相关资源
        最近更新 更多