给定:
from selenium import webdriver
import os
def setUp_Browser():
if 'nt' in os.name.lower():
# import psutil
# for proc in psutil.process_iter():
# if proc.name() == "chromedriver.exe":
# proc.kill()
time.sleep(1)
caps = webdriver.DesiredCapabilities.CHROME.copy()
caps['goog:loggingPrefs'] = {'performance': 'ALL'}
options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")
options.add_argument('ignore-certificate-errors')
options.add_argument("--incognito")
caps['acceptInsecureCerts'] = True
import pathlib
projectDir = str(pathlib.Path(__file__).parent.absolute()) + "\Resources\Drivers\"
executable_path = os.path.join(projectDir, "chromedriver.exe")
self.browser = webdriver.Chrome(executable_path=executable_path, options=options, desired_capabilities=caps)
time.sleep(3)
self.browser.get(url='www.google.ro')
self.browser.implicitly_wait(15)
time.sleep(4)
我无法访问任何给定的url,它总是在最新的驱动程序更新后引发无效的arg异常:
File "C:UsersMunteanuGAppDataLocalProgramsPythonPython38libsite-packagesseleniumwebdriverremotewebdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:UsersMunteanuGAppDataLocalProgramsPythonPython38libsite-packagesseleniumwebdriverremotewebdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:UsersMunteanuGAppDataLocalProgramsPythonPython38libsite-packagesseleniumwebdriverremoteerrorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument
(Session info: chrome=91.0.4472.101)
再发一些文字,这样我就可以发布问题了。。。。。。。。。。。
添加http或https,并删除"www.";从url似乎工作fime