为什么XPath在Chrome84中没有突出显示黄色标记? [英] Why XPath does not highlighted the yellow mark in Chrome84?
问题描述
为什么XPath不能突出显示黄色标记?我尝试在 www.google.com
Why XPath does not highlight the yellow mark? I try to find the XPath at www.google.com
//*[@id="fakebox-input"]
在Chrome上已找到但没有突出显示黄色标记,因此我很难确切地知道XPath在哪里,以及查看XPath是否正确.
It is found but not highlighted being the yellow mark on Chrome so it's hard for me to found out exactly where is the XPath and to see the XPath correct or not.
这个问题有解决方案吗?
Is there a solution to this issue?
推荐答案
Here the major issue is with DevTools within Google Chrome 84.0 which doesn't highlights the first matched element.
如果定位器找到一个匹配项,则搜索结果的确显示为 1 of 1
,但 DOM树
Incase, the locator finds a single match, the search result does show 1 of 1
but the WebElement is not highlighted within the DOM Tree
例如, Google主页中的搜索框. em> 可以使用 css-选择器:
As an example, the Search Box within the Google Home Page can be identified uniquely using the css-selector:
[name='q']
或使用xpath :
//*[@name='q']
但是 google-chrome Chrome浏览器84.0中的-devtools 确实找到了元素并显示1 of 1
,但该元素未突出显示.
But google-chrome-devtools within Google Chrome 84.0, does finds the element and shows 1 of 1
but the element is not highlighted.
但是,如果有多个元素与定位器策略,省略第一个匹配的元素,其他元素突出显示.
However, if there are multiple element matching to the Locator Strategy, leaving out the first matched element, the other elements are highlighted.
Platform>DevTools
队列中通过问题1108311引发了此问题:根据cssSelector ,元素"面板中的第一个匹配元素未突出显示,并已合并到
This issue was raised in the Platform>DevTools
queue through Issue 1108311: The first matched element in the Elements panel is not getting highlighted as per the cssSelector and had been merged into Issue 1103316: Elements search does not resolveNode (highlight text, etc) on first search result where we are actively tracking the issue.
根据@bugdroid
,主要问题是由于确保搜索结果有效的检查未解决索引为0
的情况,因此所有突出显示索引0
的结果(索引
As per @bugdroid
the main issue was caused because a check to ensure the search results were valid did not account for the case where the index was 0
, so all highlight results of index 0
(index 1
to the user) were no longer highlighted.
此问题的修复是合并-已批准:
- Chrome 版本 84.0 ,然后是版本84.0.4147.89 .
- Chrome 版本 85.0 .
- Chrome浏览器Canary 版本 86.0.4201.0 .
- Chrome version 84.0 later then Version 84.0.4147.89.
- Chrome version 85.0.
- Chrome Canary version 86.0.4201.0.
您还有另外两种(2)解决方案,如下所示:
You have two(2) other approaches as solutions as follows:
- 在第一种方法中,按照文章修复网站问题新的问题"标签,您可以在顶部第二个抽屉中的新添加的"
Console
"标签中使用命令document.querySelector()
,以通过 css-selector查询元素如下:
- In the first approach, as per the article Fix site issues with the new Issues tab you can use the command
document.querySelector()
through the newly addedConsole
tab within the second Drawer from the top to query the element through the css-selector as follows:
-
在另一种方法中,您可以单击
Element
选项卡旁边的Console
选项卡,并执行以下xpath/css命令之一:
In the other approach, you can click on the
Console
tab, next toElement
tab and execute the either of the following xpath/css commands:
-
xpath 命令为:
$x("//*[@name='q']")
标识快照:
Snapshot of identification:
-
css-selectors 命令为:
$$("[name='q']")
标识快照:
Snapshot of identification:
这篇关于为什么XPath在Chrome84中没有突出显示黄色标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!