默认情况下,chrome 将使用以下命令行运行:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
--disable-hang-monitor
--disable-prompt-on-repost
--dom-automation
--full-memory-crash-report
--no-default-browser-check
--no-first-run
--disable-background-networking
--disable-sync
--disable-translate
--disable-web-resources
--safebrowsing-disable-auto-update
--safebrowsing-disable-download-protection
--disable-client-side-phishing-detection
--disable-component-update
--disable-default-apps
--enable-logging
--log-level=1
--ignore-certificate-errors
--no-default-browser-check
--test-type=ui
--user-data-dir="C:\Users\nik\AppData\Local\Temp\scoped_dir1972_4232"
--testing-channel=ChromeTestingInterface:1972.1
--noerrdialogs
--metrics-recording-only
--enable-logging
--disable-zero-browsers-open-for-tests
--allow-file-access
--allow-file-access-from-files about:blank
我需要覆盖(删除)所有命令--disable-*
,因为没有等效的命令--enable-*
。
最后,我想用这个命令行运行浏览器:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
--dom-automation
--full-memory-crash-report
--no-first-run
--safebrowsing-disable-auto-update
--safebrowsing-disable-download-protection
--enable-logging
--log-level=1
--ignore-certificate-errors
--test-type=ui
--user-data-dir="C:\Users\nik\AppData\Local\Temp\scoped_dir1972_4232"
--testing-channel=ChromeTestingInterface:1972.1
--noerrdialogs
--metrics-recording-only
--enable-logging
--allow-file-access
--allow-file-access-from-files about:blank
例如,我尝试使用翻译信息栏运行浏览器。我找到了选项--enable-translate
。
capabilities = DesiredCapabilities.CHROME.copy()
capabilities['chrome.switches'] = ['--enable-translate']
但这并没有帮助,信息栏没有出现。在命令行中,有两个命令:--disable-translate
和--enable-translate
。这是因为必须删除命令--disable-default-apps