Using Selenium to Navigate to a URL

Below is a code sample instructing Selenium to navigate to a URL

// 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");
	}
}

We create a WebDriver object for Firefox. Then we use the driver to instruct Firefox to load the URL via the get method.

Leave a Comment