Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebDriver: set initial URL

I use WebDriver Java bindings. Creating a FirefoxDriver instance launches the Firefox browser with the 'firstrun' page: https://www.mozilla.org/en-US/firefox/42.0/firstrun/learnmore/ . It takes some time to load this page.

I want Firefox to start from "about:blank" to make the initialization faster. For Internet Explorer this can be done by:

DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "about:blank");
new InternetExplorerDriver(cap);

How to do the same for Firefox and Chrome?

like image 436
al0 Avatar asked Sep 16 '25 09:09

al0


1 Answers

Firefox:

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.startup.homepage", "about:blank");
profile.setPreference("startup.homepage_welcome_url", "about:blank");
profile.setPreference("startup.homepage_welcome_url.additional", "about:blank");
WebDriver driver = new FirefoxDriver(profile);
like image 99
al0 Avatar answered Sep 17 '25 23:09

al0