栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

IE和Chrome无法与Selenium2 Python一起使用

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

IE和Chrome无法与Selenium2 Python一起使用

在python-selenium

webdriver.Ie
中,这只是执行 IEDriver.exe
并通过进行连接的快捷方式
webdriver.Remote
。例如,您可以从命令行启动 IEDriver.exe

> IEDriverServer.exeStarted InternetExplorerDriver server (64-bit)2.39.0.0Listening on port 5555

并替换

webdriver.Ie()
为以下代码:

webdriver.Remote(command_executor='http://127.0.0.1:5555',      desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)`

您将得到相同的结果。

具体而言,很可能您具有一些系统代理设置,这些设置会强制其通过代理服务器连接到 127.0.0.1
。可能当您按照答案Python:禁用urllib2中的http_proxy所述禁用它时,可以解决此问题:

import seleniumimport urllib2from contextlib import contextmanager@contextmanagerdef no_proxies():    orig_getproxies = urllib2.getproxies    urllib2.getproxies = lambda: {}    yield    urllib2.getproxies = orig_getproxieswith no_proxies():    driver = selenium.webdriver.Ie()    driver.get("http://google.com")


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/625516.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号