使用IE8中的开发人员工具验证xpath是否有效 [英] Verify xpath is valid with developer tools in IE8

查看:1196
本文介绍了使用IE8中的开发人员工具验证xpath是否有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写selenium测试,我需要支持IE8。

I'm writing selenium tests and I need to support IE8.

我想在IE8中使用Developer Tools来验证IE8能否通过xpath找到某些元素。我可以使用Firefox的Firebug轻松地做到这一点,但是我无法弄清楚如何使用IE开发者工具 - 对于来自Chrome和Firebug的人来说,感觉非常笨重,外表和不直观。

I want to use Developer Tools in IE8 to verify that IE8 can find certain elements by their xpaths. 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.

尝试使用Developer Tools获取元素的xpath。 (网络上有很多关于如何做到这一点的链接。)我正在尝试使用开发人员工具验证我已经拥有的 将在IE8中工作。

I'm not trying to get an element's xpath with Developer Tools. (The web has plenty of links for how to do that.) I'm trying to verify that xpaths which I already have will work in IE8 using Developer Tools.

如果我想验证xpath在Chrome中找到一个元素,我会:

If I want to verify that an xpath finds an element in Chrome, I would:


  • 导航到页面I想验证

  • 按F12调出Chrome调试器

  • 按ctrl + f调出查找

  • 键入或粘贴我要测试的xpath表达式

  • 查看xpath是否找到了元素。

  • Navigate to the page I want to verify
  • Press F12 to bring up Chrome debugger
  • Press ctrl + f to bring up find
  • Type or paste in the xpath expression that I want to test
  • See if the xpath found an element.

以下是Chrome中的图片:

Here is an image of what it looks like in Chrome:

我想在IE8中做同样的事情。
我该怎么做?

I would like to do the same thing in IE8. How can I do this?

我见过等同于Firebug的复制Xpath在Internet Explorer中?试图从webelement获取xpath。我正在尝试相反的做法:从xpath获取webelement以验证xpath在IE8中是否有效。

I have seen Equivalent of Firebug's "Copy Xpath" in Internet Explorer? which tries to get the xpath from the webelement. I'm trying to do the opposite: get the webelement from the xpath to verify the xpath is valid in IE8.

推荐答案

这是不可能的,或者至少是不可能的。

This isn't possible, or at least easily.

IE(任何版本)都没有本机XPath引擎。 Selenium解决这个问题的方法是使用JavaScript库来实现它,称为Wicked Good XPath。

IE (any version) doesn't have a native XPath engine. The way Selenium works around this is by using a JavaScript library to do it, called Wicked Good XPath.

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

我唯一的建议是将WGX注入你的页面,然后直接在控制台中使用它。

My only suggestion would be to inject WGX into your page and then use it directly in the console.

但是,您仍然可以在IE Developer Tools控制台中本地执行CSS选择器 - 但这对您的XPath需求几乎没有安慰。

You can, however, still execute CSS selectors natively in the IE Developer Tools console - but this is little consolation for your XPath needs.

这篇关于使用IE8中的开发人员工具验证xpath是否有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆