xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

how to run XPath in Chrome console All In One

how to run XPath in Chrome console All In One

Command Line API

Command Line API 详情

image

https://developer.chrome.com/docs/devtools/console/utilities/#xpath-function

Chrome console API

https://developer.chrome.com/docs/devtools/console/api/

Chrome console & Command Line API

$;
ƒ $(selector, [startNode]) { [Command Line API] }

$$;
ƒ $$(selector, [startNode]) { [Command Line API] }

$x;
ƒ $x(path [, startNode]) { [Command Line API] }

update 2022.11.25

$;
ƒ $() { [native code] }
$.toString();
'function $(selector, [startNode]) { [Command Line API] }'

$$;
ƒ $$() { [native code] }
$$.toString();
'function $$(selector, [startNode]) { [Command Line API] }'

$x;
ƒ $x() { [native code] }
$x.toString();
'function $x(xpath, [startNode]) { [Command Line API] }'

image

XPath 从 1 开始计算

image

solutions

  1. $x() function
$x;
// ƒ $x() { [native code] }
$x(`/html/head/meta`);

// (28) [meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta, meta]

image

  1. 快捷键 Command + F

在 Elements Panel 搜索

image

  1. $$() function ❌
$$;
// ƒ $$() { [native code] }
$$(`/html/head/meta`);
// Uncaught DOMException: Failed to execute '$$' on 'CommandLineAPI': '/html/head/meta' is not a valid selector.

image

XPath

W3C Standards

https://www.w3.org/TR/xpath/

demo

image

https://cuiqingcai.com/202231.html

refs

https://stackoverflow.com/questions/22571267/how-to-verify-an-xpath-expression-in-chrome-developers-tool-or-firefoxs-firebug

https://www.bitdegree.org/learn/chrome-command-line



©xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-11-25 09:22  xgqfrms  阅读(52)  评论(4编辑  收藏  举报