回答

0

是的,它可以实例ChromeDriver使用两个DesiredCapabilitiesChromeOption到如下设置所需的主页: -

DesiredCapabilities capabilities = DesiredCapabilities.chrome(); 

Map<String, Object> preferences = new HashMap<String, Object>(); 
preferences.put("browser.startup.homepage", "http://my.home.page"); 
preferences.put("browser.startup.page", START_WITH_HOME_PAGE); 

ChromeOptions options = new ChromeOptions(); 
options.setExperimentalOption("prefs", preferences); 

capabilities.setCapability(ChromeOptions.CAPABILITY, options); 

WebDriver driver = new ChromeDriver(capabilities); 
+0

它不回答这个问题。你不是使用能力和chrome选项设置chrome的主页。你正在使用的功能和选项,然后只使用'driver.get()'# –

+0

@ParkerBeck啊导航到所需的页面啊,多亏了指出,实际上我不明白这个问题,现在更新与纠正... .. :) –

+1

嗨Saurabh Gaur,请更正我,我无法获得START_WITH_HOME_PAGE。我们需要在这里传递URL吗?我是无法将START_WITH_HOME_PAGE解析为变量的网路凝聚失误 –

0

只是要清楚,你正试图在这里设置的能力是选择你用于定制和配置ChromeDriver会话 以下是你可以用它来为会议设置键:

"browser.startup.homepage", "startup.homepage_welcome_url", "startup.homepage_welcome_url.additional"等 你可以通过URL这些,或者如果你不想让你也可以设置类似信息:"about:blank"作为价值