Использование новой функции веб-драйвера SeleniumPython

Программы на Python
Anonymous
Использование новой функции веб-драйвера Selenium

Сообщение Anonymous »

Я использую Selenium уже много лет, но похоже, что они изменили способ его использования, и я не получаю ничего, кроме ошибок. Вот что я пробовал:

Код: Выделить всё

from selenium import webdriver
driver = webdriver.Edge('Downloads/msedgedriver.exe')
driver.get('https://www.google.com')

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\common\driver_finder.py in get_path(service, options)
37         try:
---> 38             path = SeleniumManager().driver_location(options) if path is None else path
39         except Exception as err:

~\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\common\selenium_manager.py in driver_location(self, options)
70
---> 71         browser = options.capabilities["browserName"]
72

AttributeError: 'str' object has no attribute 'capabilities'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
 in 
1 from selenium import webdriver
2 # driver = webdriver.Edge()
----> 3 driver = webdriver.Edge('Downloads/msedgedriver.exe')
4 driver.get('https://www.google.com')

~\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\edge\webdriver.py in __init__(self, options, service, keep_alive)
48             options,
49             service,
---> 50             keep_alive,
51         )

~\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\chromium\webdriver.py in __init__(self, browser_name, vendor_prefix, options, service, keep_alive)
49         self.service = service
50
---> 51         self.service.path = DriverFinder.get_path(self.service, options)
52
53         self.service.start()

~\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\common\driver_finder.py in get_path(service, options)
38             path = SeleniumManager().driver_location(options) if path is None else path
39         except Exception as err:
---> 40             msg = f"Unable to obtain driver for {options.capabilities['browserName']} using Selenium Manager."
41             raise NoSuchDriverException(msg) from err
42

AttributeError: 'str' object has no attribute 'capabilities'

Код: Выделить всё

from selenium import webdriver
driver = webdriver.Edge()
driver.get('https://www.google.com')

---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
~\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\common\driver_finder.py in get_path(service, options)
37         try:
---> 38             path = SeleniumManager().driver_location(options) if path is None else path
39         except Exception as err:

~\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\common\selenium_manager.py in driver_location(self, options)
89
---> 90         output = self.run(args)
91

~\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\common\selenium_manager.py in run(args)
137         if completed_proc.returncode:
--> 138             raise WebDriverException(f"Unsuccessful command executed: {command}.\n{result}{stderr}")
139         return result

WebDriverException: Message: Unsuccessful command executed: C:\Users\user\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser MicrosoftEdge --output json.
{'code': 65, 'message': 'error sending request for url (https://msedgedriver.azureedge.net/LATEST_RELEASE_127_WINDOWS): error trying to connect: An existing connection was forcibly closed by the remote host.  (os error 10054)', 'driver_path': '', 'browser_path': ''}

The above exception was the direct cause of the following exception:

NoSuchDriverException                     Traceback (most recent call last)
 in 
1 from selenium import webdriver
----> 2 driver = webdriver.Edge()
3 # driver = webdriver.Edge('Downloads/msedgedriver.exe')
4 driver.get('https://www.google.com')

~\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\edge\webdriver.py in __init__(self, options, service, keep_alive)
48             options,
49             service,
---> 50             keep_alive,
51         )

~\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\chromium\webdriver.py in __init__(self, browser_name, vendor_prefix, options, service, keep_alive)
49         self.service = service
50
---> 51         self.service.path = DriverFinder.get_path(self.service, options)
52
53         self.service.start()

~\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\common\driver_finder.py in get_path(service, options)
39         except Exception as err:
40             msg = f"Unable to obtain driver for {options.capabilities['browserName']} using Selenium Manager."
---> 41             raise NoSuchDriverException(msg) from err
42
43         if path is None or not Path(path).is_file():

NoSuchDriverException: Message: Unable to obtain driver for MicrosoftEdge using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
Я пробовал разные советы, но хочу избежать самой загрузки, поскольку это для работы, а любая загрузка требует вмешательства ИТ-специалистов, что всегда является препятствием. Любая помощь будет оценена по достоинству.

Подробнее здесь: https://stackoverflow.com/questions/788 ... er-feature

Вернуться в «Python»