Demonstrating usage of Selenium through a test application.
The following prerequisites to run a demo Selenium test script:
- Java SDK in our respective Operating System.
- A Java-based IDE such as Eclipse or IntelliJ.
- A Selenium Web Driver to be added as a dependency to Java IDE.
package DemoTest;
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 we run the above script in a Java IDE, we’ll get the following execution logs displayed in your IDE window.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.