【问题标题】:Which plug-ins used to find locators in Google Chrome Browser?哪些插件用于在 Google Chrome 浏览器中查找定位器?
【发布时间】:2015-06-11 21:36:08
【问题描述】:

您好,我是 Selenium WebDriver 的新手。我有一些小疑问。 (1)。在 Firefox 浏览器中,我们过去常常通过 Firebug 插件来查找定位器。同样,Google Chrome 浏览器也有任何选项。 (2)。执行脚本时哪个定位器快得多。

【问题讨论】:

标签: java google-chrome selenium-webdriver testng


【解决方案1】:

如 cmets 中所述,按 F12 获得开发者工具。

$x("//div[@id='myId']")

如果内容在 iFrame 中,首先找到 iframe 元素并将其作为第二个参数传递:

myframe = document.getElementsByTagName("iframe")[0].contentWindow.document.body;
$x("//div[@id='myId']", myframe)

CSS 选择器也可以通过以下方式检查:

$$("#mycssSelector")

感谢我收藏并经常使用的这个答案:How to search DOM elements using XPath or CSS selectors in Chrome Developer Tools?

【讨论】:

    猜你喜欢
    • 2010-09-12
    • 2015-03-17
    • 1970-01-01
    • 2010-09-19
    • 2013-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-29
    相关资源
    最近更新 更多