1.

Demonstrate usage of Selenium through a test application.

Answer»

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 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.



Discussion

No Comment Found