简体   繁体   English

验证XPath对Internet Explorer 8中的开发人员工具有效

[英]Verify XPath is valid with developer tools in Internet Explorer 8

I'm writing Selenium tests, and I need to support Internet Explorer 8. 我正在编写Selenium测试,我需要支持Internet Explorer 8。

I want to use Developer Tools in Internet Explorer 8 to verify that Internet Explorer 8 can find certain elements by their XPath expressions. 我想在Internet Explorer 8中使用开发人员工具来验证Internet Explorer 8是否可以通过其XPath表达式查找某些元素。 I can do this easily using Chrome of Firebug with Firefox, but I can't figure out how to do it with IE Developer Tools -- it feels very clunky, foreign, and unintuitive for someone coming from Chrome and and Firebug with Firefox. 我可以使用Firefox for Firebug轻松地做到这一点,但是我无法弄清楚如何使用IE开发者工具 - 对于来自Chrome和Firebug和Firefox的人来说,它感觉非常笨拙,异国情调和不直观。

I'm not trying to get an element's XPath expression with Developer Tools. 不是想用Developer Tools来获取元素的XPath表达式。 (The web has plenty of links for how to do that.) I'm trying to verify that XPath expressions which I already have will work in Internet Explorer 8 using Developer Tools. (Web有很多链接可以解决这个问题。)我正在尝试验证我已经拥有的 XPath表达式是否可以在Internet Explorer 8中使用开发人员工具。

If I want to verify that an XPath expression finds an element in Chrome, I would: 如果我想验证XPath表达式在Chrome中找到一个元素,我会:

  • Navigate to the page I want to verify 导航到我要验证的页面
  • Press F12 to bring up Chrome debugger F12打开Chrome调试器
  • Press Ctrl + F to bring up find Ctrl + F调出查找
  • Type or paste in the XPath expression that I want to test 键入或粘贴我要测试的XPath表达式
  • See if the XPath expression found an element. 查看XPath表达式是否找到了一个元素。

Here is an image of what it looks like in Chrome: 以下是Chrome中的图片:

在Chrome中验证XPath表达式

I would like to do the same thing in Internet Explorer 8. How can I do this? 我想在Internet Explorer 8中做同样的事情。我该怎么做?

I have seen Equivalent of Firebug's “Copy Xpath” in Internet Explorer? 在Internet Explorer中看到了Firebug的“Copy Xpath”等价? which tries to get the XPath expression from the webelement. 它试图从webelement获取XPath表达式。 I'm trying to do the opposite: get the webelement from the XPath expression to verify the XPath expression is valid in Internet Explorer 8. 我正在尝试相反的做法:从XPath表达式中获取webelement以验证XPath表达式在Internet Explorer 8中是否有效。

This isn't possible, or at least easily. 这是不可能的,或者至少是不容易的。

Internet Explorer (any version) doesn't have a native XPath engine. Internet Explorer(任何版本)没有本机XPath引擎。 The way Selenium works around this is by using a JavaScript library to do it, called Wicked Good XPath. Selenium解决这个问题的方法是使用JavaScript库来实现它,称为Wicked Good XPath。

https://code.google.com/p/wicked-good-xpath/ https://code.google.com/p/wicked-good-xpath/

My only suggestion would be to inject WGX into your page and then use it directly in the console. 我唯一的建议是将WGX注入您的页面,然后直接在控制台中使用它。

You can, however, still execute CSS selectors natively in the IE Developer Tools console - but this is little consolation for your XPath needs. 但是,您仍然可以在IE Developer Tools控制台中本地执行CSS选择器 - 但这对您的XPath需求几乎没有任何安慰。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 等价于Internet Explorer中Firebug的“复制XPath”吗? - Equivalent of Firebug's “Copy XPath” in Internet Explorer? Selenium JAVA xPath Firefox与Internet Explorer - Selenium JAVA xPath Firefox vs Internet Explorer Internet Explorer 11 中是否有本机 XPath 支持? - Is there a native XPath support in Internet Explorer 11? 硒:Concat xpath函数在Internet Explorer中不起作用 - selenium: Concat xpath function is not working in internet explorer Selenium 找不到元素,尽管 xpath 可以在开发人员工具中使用 - Selenium cannot find element, allthough xpath works in developer tools 在Internet Explorer中使用Xpath无法找到硒中的元素 - Unable locate element in selenium using Xpath in internet explorer Python Selenium Internet explorer 找不到 css 选择器,或 Z3D788FA62D7C74105A1BEE4C91 - Python Selenium Internet explorer not able to find css selector, or xpath 为什么 selenium/python/chromedriver 无法识别 Chrome 开发人员控制台中的有效 xpath? - Why is valid xpath in chrome developer console not recognized by selenium / python / chromedriver? 硒。 Webdriver。 IE浏览器。 无法评估// body XPath - Selenium. Webdriver. Internet Explorer. Unable to evaluate //body XPath Selenium Xpath问题在特定位置验证特定图像-Internet Explorer 9(IE9) - Selenium Xpath issue verifying specific image at specific location - Internet Explorer 9 (IE9)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM