Selenium:InternetExplorerDriver:禁用 JavaScript [英] Selenium: InternetExplorerDriver: disable JavaScript

查看:42
本文介绍了Selenium:InternetExplorerDriver:禁用 JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 InternetExplorerDriver 禁用 JavaScript?

How do I disabled JavaScript using the InternetExplorerDriver?

我有以下内容,但它似乎没有禁用 JavaScript:

I have the following but it doesn't seem to disable JavaScript:

self.selenium = webdriver.Remote(
   command_executor="http://localhost:4444/wd/hub",
   desired_capabilities={
       'platform': 'WINDOWS',
       'browserName': 'internet explorer',
       'version': '', 
       'javascriptEnabled': False})

推荐答案

您不能在 IE 驱动程序中禁用 JavaScript.您请求的 DesiredCapabilities 不一定是创建的驱动程序实例的功能.也就是说,如果驱动程序不支持您请求的功能,它不会抛出错误;相反,它返回驱动程序实例正在使用的实际功能.这个问题更多地讨论了 WebDriver 的这个特定细节API.

You can't disable JavaScript in the IE driver. The DesiredCapabilities you request are not necessarily the capabilities of the created driver instance. That is, the driver does not throw an error if it does not support the capabilities you request; rather, it returns the actual capabilities the driver instance is using. This question talks more about this particular detail of the WebDriver API.

此外,IE 驱动程序(实际上是目前所有的驱动程序)的大部分功能都是在 JavaScript 中实现的.这意味着禁用 JavaScript 会使大部分 IE 驱动程序(实际上是目前的所有驱动程序)变得无用.

Furthermore, much of the functionality of the IE driver (and indeed all drivers at present) is implemented in JavaScript. That means disabling JavaScript would render large parts of the IE driver (and indeed all drivers at present) useless.

这篇关于Selenium:InternetExplorerDriver:禁用 JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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