Reputation: 704
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.
Upvotes: 4
Views: 6757
Reputation: 31
options.AddArgument("--homepage \"url\""); like this, set null homepage: options.AddArgument("--homepage \"data:,\"");
Upvotes: 1
Reputation: 208
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();
capabilities.setCapability("chrome.switches",
Arrays.asList("--homepage=http://somesite.com/"));
WebDriver driver = new ChromeDriver(capabilities);
Upvotes: 6
Reputation: 29032
I think you have 3 possible options here. (1 may not be)
Design your own get
method which will execute javascript. something like,
window.location.replace("http://somesite.com/")
so it will not be logged into history.
In your validations, just make sure you validate n-1
to "pretend" it wasn't there.
Using the JavascriptExecutor, find out a way that you can modify the history
object and just take that initial about:blank
history entry out.
Upvotes: 0