Selenium get() Method

get(String url)

Description: This method loads a new web page in the current browser window. It waits until the page is fully loaded before returning control to the script.

Use case: Useful for navigating to any website or URL.

Example:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class SeleniumExample {
    public static void main(String[] args) {
        // Set the path to your WebDriver executable (e.g., chromedriver)
        System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");

        // Create an instance of the ChromeDriver
        WebDriver driver = new ChromeDriver();

        // Use the get() method to navigate to a website
        driver.get("https://www.example.com");

        // Perform actions on the webpage, such as interacting with elements

        // Close the browser
        driver.quit();
    }
}