I want to try automation using Selenium in python. I have installed Selenium 4.10.0 and change the webdriver and browser (Edge) to version 113.0.1774.35. I am using VSCodes in my MacBook.
This is my code:
from selenium import webdriver
driver=webdriver.Edge('/Users/ME/Documents/Drivers/EdgeDriver/msedgedriver')
driver.get('https://www.google.com')
print('Press any key to continue...')
I am having an issue saying:
Exception has occurred: ValueError
Timeout value connect was \<object object at 0x100800460\>, but it must be an int, float or None.
TypeError: float() argument must be a string or a real number, not 'object'
During handling of the above exception, another exception occurred:
File "/Users/aethelflaed/Documents/Coding Python/First_Selenium.py", line 2, in \<module\>
driver=webdriver.Edge('/Users/ME/Documents/Drivers/EdgeDriver/msedgedriver')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Timeout value connect was \<object object at 0x100800460\>, but it must be an int, float or None.
Is there anything else I am missing to work with Selenium in python?
This is due to changes in selenium
4.10.0
:
https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e
Note that the first argument is no longer executable_path
, but options
. (That's why you got the error.)
If you want to pass in an executable_path
, you'll have to use the service
arg now. This is how you should start Edge:
from selenium import webdriver
from selenium.webdriver.edge.service import Service
service = Service(executable_path="PATH_TO_msedgedriver")
options = webdriver.EdgeOptions()
driver = webdriver.Edge(service=service, options=options)
# ...
driver.quit()
Passing in the executable_path
is optional. If it's not on your PATH, it will automatically get downloaded using the new selenium manager that's included.