使用Selenium更改Chrome的设置 [英] Changing Chrome's settings with Selenium
问题描述
我正在使用Selenium在Chrome上工作,并且希望使用Webdriver在Chrome中更改一些设置.使用Google和此网站,我可以使大多数设置生效.但是,似乎还有一些逃脱了我,希望我能在这里得到答案.我希望在启动浏览器之前更改设置,例如使用ChromeOptions
,而不是使用自动化来导航设置页面.
I'm working on Chrome with Selenium and I'm looking to change a few settings within Chrome using the webdriver. Using Google and this site, I was able to get most of the settings working. However, a few more seem to escape me and hopefully I can get the answers here. I'm looking to alter the settings before launching the browser, such as using ChromeOptions
, rather than using automation to navigate the settings page.
我要更改的设置如下:
- 禁用Java语言
- 禁用麦克风
- 更改主页
- 更改多功能框中的默认搜索引擎
这4个给我的问题最多.有帮助吗?
These 4 are giving me the most issues. Any help?
推荐答案
也许这列表Chromium命令行开关将有所帮助.例如
Perhaps this List of Chromium Command Line Switches will help. E.g.
DesiredCapabilities caps = DesiredCapabilities.chrome();
caps.setCapability("chrome.switches", Arrays.asList("--disable-javascript"));
还有
Map<String, Object> preferences = Maps.newHashMap();
preferences.put( "browser.startup.homepage", "http://my.home.page" );
preferences.put( "browser.startup.page", START_WITH_HOME_PAGE );
capabilities.setCapability( ChromeOptions.CAPABILITY, preferences );
ChromeDriver driver = new ChromeDriver( capabilities );
更新
我的猜测是以下
"import_search_engine": true
来自配置其他参数,将导致Chrome要求您选择搜索引擎打开时.
from Configuring other parameters will cause Chrome to ask you to select a search engine when it opens.
关闭JavaScript会使chrome几乎无法操作;我认为不支持该选项.对于麦克风,这更多是系统选项.对于麦克风的about:config的搜索为空.
Turning off JavaScript makes chrome pretty much a no-op; I do not think that the option is supported. As far as microphones, that is more a system option. A search of about:config for microphone came up empty.
这篇关于使用Selenium更改Chrome的设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!