[英]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中找到一个元素,我会:
Here is an image of what it looks like in Chrome: 以下是Chrome中的图片:
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.