简体   繁体   中英

How to get cssSelector to Find a Element in IE 9

如何使用IE9中的开发人员工具查找cssSelector?

Pro-tip, you shouldn't be using tools to "find" or "create" selectors for you - why? Tools are going to give you the basic selector, which is not necessarily the best one.

Therefore, you need to look at and understand the CSS selector spec and actually create them yourself.

However, once you've created the selectors yourself it is quite easy to actually "run" them in IE's Developer Tools. You just need to mimic what Selenium does.

Example selector: #someID > div.something

In IE's Developer Tools, open up the Console, and type in:

document.querySelector("selector")

Which, in my example, is:

document.querySelector("#someID > div.something")

This is equivalent to your .FindElement calls, and as for your .FindElements calls:

document.querySelectorAll("selector")

Which, in my example, is:

document.querySelectorAll("#someID > div.something")

The result you get back, is what (in theory) Selenium should also be finding.

You should use firefox and add ons firebug and firepath to get the right xpath. When executing tests define the browser internet explorer or chrome or firefox or etc instead

firebug https://addons.mozilla.org/nl/firefox/addon/firebug/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM