问题
I am working on selenium (3.5.0),Python 3.6.8 i wanted to test simple code that is written below
driver.implicitly_wait(10)
driver.get(url)
print(driver.title)
sleep(6)
driver.close()
but it is throwing an error i.e
selenium.common.exceptions.WebDriverException: Message: invalid argument: value must be a non-negative integer
I am not getting where i went wrong
I found similar issue raised by someone in this platform but my problem didn't get solved please help me in this regard
回答1:
This error message...
selenium.common.exceptions.WebDriverException: Message: invalid argument: value must be a non-negative integer
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
- Presumably you are using the latest chromedriver=77.0
- Presumably you are using chrome= 77.0.
- Your Selenium Client version is 3.6.8 which is ancient.
So there is a clear mismatch between the Selenium Client v3.6.8 , ChromeDriver v77.0 and the Chrome Browser v77.0
Solution
Ensure that:
- Selenium is upgraded to current levels Version 3.141.59.
- ChromeDriver is updated to current ChromeDriver v77.0 level.
- Chrome is updated to current Chrome Version 77.0 level. (as per ChromeDriver v77.0 release notes)
- Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
- If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
- Take a System Reboot.
- Execute your
@Testas non-root user. - Always invoke
driver.quit()withintearDown(){}method to close & destroy the WebDriver and Web Client instances gracefully.
来源:https://stackoverflow.com/questions/58184784/selenium-common-exceptions-webdriverexception-message-invalid-argument-value