Using Selenium to Navigate to a URL
March 08, 2016
Below is a code sample instructing Selenium to navigate to a URL
[java]
// A basic Selenium file to open a web page in Firefox
package net.brav3.webdriver.A1;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class NavigateToAUrl {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get(”https://developer.mozilla.org”);
}
}
[/java]
We create a WebDriver object for Firefox. Then we use the driver to instruct Firefox to load the URL via the get method.