First Test Case with Selenium WebDriver



Below code is for opening a URL in google chrome by selenium webdriver. (for more information check the comment text in the code).



package mypackage;

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

public class Signup {

 public static void main(String[] args) {
  // TODO Auto-generated method stub

  //path of chrome driver and set property to your chrome driver
 String exepath = "C:\\Users\\abc\\Downloads\\chromedriver_win32//chromedriver.exe";
 System.setProperty("webdriver.chrome.driver", exepath);
 
  WebDriver driver = new ChromeDriver();
  
  //launch chrome and direct it to the URL
  driver.get("http://www.testingtreasure.com");
  
  //maximize window
  driver.manage().window().maximize();
  
  //close browser
  driver.close();
  
 }

}





No comments:

Post a Comment