QaMantra: How to Launch Chrome Browser In Selenium

How to Launch Chrome Browser In Selenium

There are certain Prerequisite required To Launch Chrome Browser :

1. Download The Latest Version of Selenium Standalone Jar  Selenium Standalone Server Latest Version

2. Download Chrome Driver  Latest version Chrome Driver Latest Version

3. Download Eclipse IDE  Eclipse IDE

4. Extract Downloaded Eclipse Zip File

Eclipse Installation Process Image

Eclipse IDE Installation Process


5. Eclipse will be open with welcome page ,Go To This Link for Detail Description of Eclipse Installation  How To Download and Install Eclipse Latest and Older Version

6.Click On File  > New  > Java Project

7. Enter Project Name as Per your wish  Like ---   'FirstjavaProject'  and click on Finish button

How To create Java New Project

How To Create Java New Project


8. Right click on  Java Project -'FirstjavaProject' >New >Folder > Enter Folder Name Like -'Jar' >Click on Finish

9. Copy Selenium Standalone jar which you have downloaded in First step and Paste Inside Folder 'Jar'  > Right Click on Selenium Standalone jar >Go To Build Path > Click On Add To Build Path

10. Right click on  Java Project -'FirstjavaProject' >New >Folder > Enter Folder Name Like -'Exe' >Click on Finish

11. Copy ChromeDriver.exe File which you have downloaded in First step and Paste Inside Folder 'Exe'

12. Click on Java Project -'FirstjavaProject' > Go to Src Folder > Right click on Src Package Folder > New > Package > Enter Package Name Like -'PackageOne'  > Click on Finish

13. Right click on Created Package- 'PackageOne'  > New > Class > Enter Class Name Like -'ChromeBrowserLaunch' > Click on Finish

14. Write a Program Like This :

package PackageOne;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class ChromeBrowserLaunch {

public static void main(String[] args) throws InterruptedException {

      // Chrome Driver Property Setting
System.setProperty("webdriver.chrome.driver", ".\\Exe\\chromedriver.exe");

               // initializing Chrome Driver
 WebDriver driver=new ChromeDriver();

              // Open Gmail Home Page
 driver.get("https://mail.google.com");
}
}

15 .Right click on Class Name -'ChromeBrowserLaunch' > Run As > Java Application





No comments: