1、使用命令行启动Chrome:
Mac:/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome -remote-debugging-port=9999
Windows:chrome.exe --remote-debugging-port=9222
2、初始化Chrome:
def setup_method(self):
chrome_options = webdriver.ChromeOptions()
chrome_options.debugger_address ="127.0.0.1:9999"
self.driver = webdriver.Chrome(options=chrome_options)
self.driver.implicitly_wait(10)
3、编写对应的脚本: