Reputation: 345
I'm using Selenium webdriver using Java and i know how to open a browser in 2 ways:
driver.get("some url")
driver.navigate().GoToUrl("some url")
Is there any option available to open a browser other than this?
Upvotes: 1
Views: 33114
Reputation: 1145
You can use Java script, there is a command window.location='url'
which can help you to achieve this.
String url = "https://www.google.com";
String script = "window.location = \'"+url+"\'";
System.setProperty("webdriver.ie.driver", "Drivers\\IEDriverServer.exe");
WebDriver driver= new FirefoxDriver();
((JavascriptExecutor) driver).executeScript(script);
But again this is NOT a recommended method.
Difference between get()
and this command is that, get() would wait for your page to load but NOT Javascript, it would just do what you command and that's it. You would need to separately manage waits then.
So if possible use the traditional methods. :)
Upvotes: 3