Why XPath does not highlighted the yellow mark in Chrome84?

南楼画角 提交于 2020-07-30 08:02:12

问题


Why XPath does not highlight the yellow mark? I try to find the XPath at www.google.com

//*[@id="fakebox-input"]

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?


回答1:


Here the major issue is with DevTools within Google Chrome 84.0 which doesn't highlights the first matched element.

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

As an example, the Search Box within the Google Home Page can be identified uniquely using the css-selector:

[name='q']

or using the xpath:

//*[@name='q']

But google-chrome-devtools within Google Chrome 84.0, does finds the element and shows 1 of 1 but the element is not highlighted.

devtools_issue

However, if there are multiple element matching to the Locator Strategy, leaving out the first matched element, the other elements are highlighted.


Bug in Chrome 84

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.


Alternate Solutions

You have two(2) other approaches as solutions as follows:

  • 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 added Console tab within the second Drawer from the top to query the element through the css-selector as follows:

query_selector_css

  • In the other approach, you can click on the Console tab, next to Element tab and execute the either of the following xpath/css commands:

    • xpath command as:

      $x("//*[@name='q']")
      
    • Snapshot of identification:

console_tab_xpath

  • css-selectors command as:

    $$("[name='q']")
    
  • Snapshot of identification:

console_tab_css-selector




回答2:


The bounty belongs to @DebanjanB however to add a quick note that they've they've now fixed this in at least Version 84.0.4147.105 (Official Build) (64-bit).

Just go to chrome://settings/help an let chrome update.

This is this page, working for a single highlight



来源:https://stackoverflow.com/questions/62945647/why-xpath-does-not-highlighted-the-yellow-mark-in-chrome84

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!