0

I just wanted to know is it possible to set homepage of Chrome using capabilities and Chrome options in Selenium.

1
  • Did you want to open the webpage from selenium Webdriver using chrome browser? Commented Aug 9, 2016 at 19:06

2 Answers 2

1

Yes it is possible to instantiate ChromeDriver with using both DesiredCapabilities and ChromeOption to set your desired Homepage as below :-

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);
3
  • It does not answer the question. You're not setting the homepage in chrome using capability and chrome options like was asked. You are using capabilities and options, and then only navigating to the desired page using driver.get() Commented Aug 9, 2016 at 19:18
  • @ParkerBeck ah, thanks to point it out, actually I didn't understand the question, now updated with correction.....:) Commented Aug 9, 2016 at 19:38
  • 1
    Hi Saurabh Gaur,please correct me, I am not able to get START_WITH_HOME_PAGE . Do we need to pass URL here? I am geeting error that START_WITH_HOME_PAGE can't be resolved to a variable Commented Aug 10, 2016 at 6:16
0

Just to be clear, the capabilities you are trying to set here are options that you use to customize and configure a ChromeDriver session. Below are the keys which you can use to set for that session:

"browser.startup.homepage", "startup.homepage_welcome_url", "startup.homepage_welcome_url.additional" etc. You can pass URL for these or if you don't want you can also set something like : "about:blank" as value

Not the answer you're looking for? Browse other questions tagged or ask your own question.