回答

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"作爲價值