首页 新闻 会员 周边

Python3.6+Selenium打不开Ie浏览器

0
[待解决问题]

【环境信息】

Python3.6+Selenium3.0.2+IE10+win7

【问题描述】

1、用如下代码打不开IE浏览器,但是能打开火狐浏览器

import unittest
import os
from selenium import webdriver

class TestAutoMethods(unittest.TestCase):
    #打开Firefox浏览器
    def test_openbrower(self):
       browser = webdriver.Firefox()
       browser.get("http://www.baidu.com")

    def test_FirstVase(self):
        #ie_driver = os.path.abspath(r"C:\Program Files(x86)\Internet Explorer\IEDriverServer.exe")
        #os.environ["webdriver.ie.driver"] = ie_driver
        browser = webdriver.Ie()
        browser.get("http://www.youdao.com")

if __name__ == '__main__':
    unittest.main()

2、报错信息

Error
Traceback (most recent call last):
  File "D:\Users\chenle\PycharmProjects\untitled\test\FirstExam.py", line 14, in test_FirstVase
    browser = webdriver.Ie()
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\ie\webdriver.py", line 57, in __init__
    desired_capabilities=capabilities)
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 234, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 408, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 478, in _request
    resp = opener.open(request, timeout=self._timeout)
  File "C:\Program Files\Python36\lib\urllib\request.py", line 526, in open
    response = self._open(req, data)
  File "C:\Program Files\Python36\lib\urllib\request.py", line 544, in _open
    '_open', req)
  File "C:\Program Files\Python36\lib\urllib\request.py", line 504, in _call_chain
    result = func(*args)
  File "C:\Program Files\Python36\lib\urllib\request.py", line 1346, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "C:\Program Files\Python36\lib\urllib\request.py", line 1321, in do_open
    r = h.getresponse()
  File "C:\Program Files\Python36\lib\http\client.py", line 1331, in getresponse
    response.begin()
  File "C:\Program Files\Python36\lib\http\client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "C:\Program Files\Python36\lib\http\client.py", line 266, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

不知道是什么原因引起的,求助大神啊

打不过小怪兽leer的主页 打不过小怪兽leer | 菜鸟二级 | 园豆:202
提问于:2017-01-10 17:09
< >
分享
所有回答(2)
0

试一试是不是framework 的版本不正确   换成framework 4.0  或者换成framework 2.0    这个问题我也没遇到过  你可以试一试

姚小丹 | 园豆:42 (初学一级) | 2017-01-10 18:01

额,请问和framework有什么关系呢?

支持(0) 反对(0) 打不过小怪兽leer | 园豆:202 (菜鸟二级) | 2017-01-11 09:11
0

浏览器驱动的版本是不是不对:IEDriverServer,参考网址:http://selenium-release.storage.googleapis.com/index.html
有对应IE浏览器和浏览器驱动对应版本。

Owen_ET | 园豆:195 (初学一级) | 2019-02-21 09:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册