小编Pra*_*ena的帖子

未捕获的 DOMException:无法在“CommandLineAPI”上执行“$”:不是有效的选择器

我正在使用 selenium 为我的网页编写自动化 UI 测试。我正在测试的网页上有一个元素:

<&lt input type="checkbox" id="screening_questions[0].multiple_choice[0]-dealbreakerField" value="on" style="position: absolute; cursor: inherit; pointer-events: all; opacity: 0; width: 100%; height: 100%; z-index: 2; left: 0px; box-sizing: border-box; padding: 0px; margin: 0px;>
Run Code Online (Sandbox Code Playgroud)

由于该元素具有 id 属性,因此我尝试使用其 id 值来定位它,但没有成功。

如果我在 chrome 控制台中搜索该元素为:

$('#screening_questions[0].multiple_choice[0]-dealbreakerField')
Run Code Online (Sandbox Code Playgroud)

我收到异常:未捕获的 DOMException:

Failed to execute '$' on 'CommandLineAPI': '#screening_questions[0].multiple_choice[0]-dealbreakerField' is not a valid selector.
Run Code Online (Sandbox Code Playgroud)

我认为根据它的 id 值可以很容易地找到它。你能建议这里有什么问题吗?

selenium xpath dom css-selectors selenium-webdriver

5
推荐指数
1
解决办法
5159
查看次数

标签 统计

css-selectors ×1

dom ×1

selenium ×1

selenium-webdriver ×1

xpath ×1