我想在python中使用Selenium來嘗試自動化。我已經安裝了Selenium 4.10. 0,并將Web驅動程序和瀏覽器(Edge)更改為113.0.1774.35版本。我在我的MacBook中使用VSCode。
這是我的代碼:
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...')
我有一個問題說:
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.
在python中與Selenium一起工作,我還缺少什么嗎?
這是由于
selenium
4.10.0
:https://github.com/SeleniumHQ/selenium/commit/9f5801c82fb3be3d5850707c46c3f8176e3ccd8e中的更改造成的請注意,第一個參數不再是
executable_path
,而是options
。(這就是你得到error.的原因)如果你想傳入一個
executable_path
,你現在必須使用service
參數。以下是啟動Edge的方式:在
executable_path
中傳球是可選的。如果它不在您的PATH上,它將使用包含的新selenium管理器自動下載。