Url запускается в chrome, но в firefox я получаю ошибку

Когда я пытаюсь запустить URL-адрес в chrome, он работает нормально, но когда я пытаюсь использовать firefox по одному и тому же URL-адресу, я получаю некоторую ошибку. Я не знаю, почему. Это говорит о том, что у меня есть некоторая ошибка подключения, а соединение отказано. Код, который я написал

    def test_setUp(self):
    browser = 'f'
    if browser == 'f':
        self.driver = webdriver.Firefox(executable_path="/home/manoj/PycharmProjects/InvitedModel/geckodriver")
        print("Run started at : " + str(datetime.datetime.now()))
        print("FireFox environment Set up")
        print("---------------------------------------------------------------------------------------------")
        self.driver.implicitly_wait(20)
        self.driver.quit()
    else:
        self.driver = webdriver.Chrome('/home/manoj/Downloads/chromedriver_linux64/chromedriver')
        print("Run started at : " + str(datetime.datetime.now()))
        print("Chrome environment Set Up")
        print("---------------------------------------------------------------------------------------------")
        self.driver.implicitly_wait(20)

    self.driver.set_window_size(1920, 1080, self.driver.window_handles[0])
    self.driver.get("https://forum.smartron.com/")

Я установил правильные драйверы gecko и FireFox версии 61.0.1

Ошибка :

Error
Traceback (most recent call last):
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/connection.py", line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/util/connection.py", line 79, in create_connection
raise err
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/util/connection.py", line 69, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/connection.py", line 196, in connect
conn = self._new_conn()
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/connection.py", line 180, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fbe29f86588>: Failed to establish a new connection: [Errno 111]    Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/lib/python3.6/unittest/case.py", line 601, in run
self.setUp()
File "/home/manoj/PycharmProjects/InvitedModel/TestBase/Environment.py", line 27, in setUp
self.driver.set_window_size(1920, 1080, self.driver.window_handles[0])
File "/home/manoj/newenv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 723, in window_handles
return self.execute(Command.W3C_GET_WINDOW_HANDLES)['value']
File "/home/manoj/newenv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 318, in execute
response = self.command_executor.execute(driver_command, params)
File "/home/manoj/newenv/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 375, in execute
return self._request(command_info[0], url, body=data)
File "/home/manoj/newenv/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/request.py", line 68, in request
**urlopen_kw)
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/request.py", line 89, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/poolmanager.py", line 322, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen
**response_kw)
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen
**response_kw)
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 667, in urlopen
**response_kw)
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/manoj/newenv/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=飗.0.0.1', port=37043): Max retries exceeded with url: /session/affe97e5-78d3-4132-82a4-e5f43dae1604/window/handles (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fbe29f86588>: Failed to establish a new connection: [Errno 111] Connection refused',))

Всего 1 ответ


Проблема заключается в строке self.driver.quit() - вы сначала self.driver.quit() из экземпляра браузера, а затем пытаетесь изменить его размер.

Переместите self.driver.quit() в конец скрипта.


Есть идеи?

10000