Logo Questions Linux Laravel Mysql Ubuntu Git Menu

How can you start a browser at a specific URL using the selenium webdriver

So if I do the following:

 driver = webdriver.Chrome() # this results in the browser displaying the about page
 driver.get("http://somesite.com/")  # now the browser goes to the URL

Then if I check the history length via the javascript console in the browser I get a value of 2. I need to simulate the situation where a new tab or window is opened with the URL and thus a history length of 1.

Thanks in advance.

like image 236
mtnpaul Avatar asked Mar 22 '23 06:03


2 Answers

You can set some specific flags to pass to your WebDriver when you initialize it. You can see examples here (for Chrome), and there is also a link to a full list of switches. Here is how to set the homepage for ChromeDriver in java:

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
WebDriver driver = new ChromeDriver(capabilities);
like image 177
eldon111 Avatar answered Apr 25 '23 18:04


options.AddArgument("--homepage \"url\""); like this, set null homepage: options.AddArgument("--homepage \"data:,\"");

like image 44
WnagoiYy Avatar answered Apr 25 '23 18:04