You need the following prerequisites to run a demo Selenium test script:
Java SDK in your respective Operating System.
A Java-based IDE such as Eclipse or IntelliJ.
A Selenium WebDriver is to be added as a dependency to Java IDE.
package scalerAcademy;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebDriver;
public class MyFirstTestClass {
public static void main(String[] args) throws InterruptedException {
//It sets the system property to the given value.
System.setProperty("webdriver.gecko.driver","D:\\Softwares\\geckodriver.exe”);
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com/");
//Launch website in the browser
driver.manage().window().maximize();
//The sleep pauses the execution of the thread for 5000 ms.
Thread.sleep(5000);
driver.quit();
}
}
Once you run the above script in a Java IDE, you’ll get the following execution logs displayed in your IDE window.