关于 selenium 4.0.0a1 版本的问题

之前发了一个帖子,关于不利用js打开新窗口的问题,今天发现selenium 4.0.0a1中
switch_to.window()方法,当赋值’tab’时,则可新打开标签
源码如下:

def new_window(self, type_hint=None):
        """Switches to a new top-level browsing context.

        The type hint can be one of "tab" or "window". If not specified the
        browser will automatically select it.

        :Usage:
            ::

                driver.switch_to.new_window('tab')
        """
        value = self._driver.execute(Command.NEW_WINDOW, {'type': type_hint})['value']
        self._w3c_window(value['handle'])

正是我所需要的,于是便更新了selenium版本,结果却出现了一个坑,尽管我

driver = webdriver.Ie(executable_path='IEDriverServer.exe')

但他总是提示

Traceback (most recent call last):
  File "e:\Dropbox\17.Develop\2.Code\08.网络\selenium\selenium01.py", line 3, in <module>
    driver = webdriver.Ie(executable_path='IEDriverServer.exe')
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\selenium\webdriver\ie\webdriver.py", line 91, in __init__
    service = Service()
TypeError: __init__() missing 1 required positional argument: 'executable_path'

顺着源码找去

if service is None:

            service = Service()

        self.iedriver = Service(

            executable_path,

            port=self.port,

            host=self.host,

            log_level=log_level,

            log_file=service_log_path)

        self.iedriver.start()

郁闷的我在

service = Service()

中赋了个值
service = Service(executable_path=executable_path)
结果,那个错误提示不出现了,
却又回到了以下错误

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "e:\Dropbox\17.Develop\2.Code\08.网络\selenium\selenium01.py", line 3, in <module>
    driver = webdriver.Ie(executable_path='IEDriverServer.exe')
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\selenium\webdriver\ie\webdriver.py", line 101, in __init__
    RemoteWebDriver.__init__(
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 152, in __init__
    self.start_session(capabilities, browser_profile)
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 249, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 316, in execute
    response = self.command_executor.execute(driver_command, params)
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 375, in execute
    return self._request(command_info[0], url, body=data)
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 403, in _request
    resp = http.request(method, url, body=body, headers=headers)
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\urllib3\request.py", line 79, in request
    return self.request_encode_body(
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\urllib3\request.py", line 171, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\urllib3\poolmanager.py", line 330, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\urllib3\connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\urllib3\connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\urllib3\connectionpool.py", line 747, in urlopen
    return self.urlopen(
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\urllib3\connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "E:\Dropbox\17.Develop\2.Code\08.网络\selenium\env\lib\site-packages\urllib3\util\retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=80): Max retries exceeded with url: /session (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001F5D70E9B50>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!