Selenium + IE8:强制IE8兼容性视图 [英] Selenium + IE8: force IE8 compatibility view

查看:1049
本文介绍了Selenium + IE8:强制IE8兼容性视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在单窗口模式和IE8中运行Selenium。

I'm running Selenium in singleWindow mode and IE8.

如果我手动启动IE8,则设置IE8模式,但是当我使用Selenium启动时,模式使用兼容模式设置为IE7。

If i start IE8 manually the IE8 mode is set, but when i launch it with Selenium, the mode set is IE7 using the compatibility mode.

在使用Selenium启动浏览器时,任何人都知道为什么兼容模式不是IE8视图?

Anyone knows why the compatibility mode is not the IE8 view when launching the browser with Selenium?

或者,我如何完全禁用IE中的兼容模式并强制它始终使用IE8视图?

Or, how can i disable totally the compatibility mode in IE and force it to use always the IE8 view?

推荐答案

我给了一个+1的问题,因为这是一个非常好的问题 - 如何做到这一点并不明显,如果你需要测试这两种模式,那么这是必要的事情。

I've given the question a +1 because it's a very good question -- it's not obvious how to do this, and if you need to test both modes, then it is a necessary thing to do.

您可以让网站服务< meta http-equiv =X-UA-Compatiblecontent =IE = 7/> 。这应该强制输出模式。

You could get the site to serve <meta http-equiv="X-UA-Compatible" content="IE=7" /> within the page when running the tests. This should force the output mode.

显然,这并不理想,因为这意味着更改代码以按需生成元标记。我通常认为如果你不得不改变主代码库来为你的测试套件的特定用途添加代码,这是件坏事,但在这种情况下我看不到任何其他解决方案。

Obviously, that's not ideal, because it means changing your code to produce the meta tag on demand. I'd normally consider it a bad thing if you're having to change the main codebase in to add code for the specific use of your test suite, but in this case I can't see any other solution.

鉴于我们已决定沿着这条路走下去,您可以编写代码来接受URL中指定的参数,该参数触发要提供的元标记。然后可以编写IE7测试来发送该URL参数。

Given that we've decided to go down this path, you could write your code to accept a specified argument in the URL that triggers the meta tag to be served. The IE7 tests could then be written to send that URL argument.

顺便说一下,值得指出IE8的IE7兼容模式与IE7不是100%相同;它有自己的怪癖和错误,它们与真正的IE7浏览器不同。在大多数情况下它应该没问题,但如果你期望你的测试确认该网站在IE7中工作,那么值得注意这一点。请参阅此博文了解更多信息

By the way, it's worth pointing out that IE8's IE7-compatibility mode is not 100% identical to IE7; it has its own quirks and bugs which are distinct from those of a real IE7 browser. For the most part it should be fine, but it's worth being aware of this if you're expecting your tests to confirm that the site works in IE7. See this blog post for more info

这篇关于Selenium + IE8:强制IE8兼容性视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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