How to run the selenium scripts in chrome browser?

Running the selenium scripts in chrome browser is easy. Chrome driver is developed by third party and it is not developed by seleniumhq.org.  Also chrome browser is a light weight browser it will take less time to invoke the browser.  I usually will use the chrome driver for my Facebook Automation or Google Plus automation. With my scripts i can post my status more than 500 groups without any drop until unless the internet connection is not good. Going forward after you understand the selenium scripts how it works you will be able to write web browser automation scripts efficiently.  But keep on practice until you are familiar.

ChromeDriver link has given below. Download it and save it to your local drive.
Once you had saved you need to mention the path in the selenium scripts.

Download Link : ChromeDriver

One thing people may get confuse using backslash(\) or forward slash(/) to mention the path. For example, our driver saved place it will be like this with single backslash : "C:\Selenium\ChromeDriver.exe". But, We should mention the path with double forward slash in the selenium scripts as "C://Selenium//chromedriver.exe"

Code:
import java.util.*;
import java.util.concurrent.TimeUnit;   
import org.openqa.selenium.*;   
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.WebDriverWait;

public class FB_LoginPage {
 
private static WebDriver driver = null;   
  
public static void main(String[] args) 
throws InterruptedException, IOException {   

//Create a new instance of the Chrome driver  
//- chromedriver.exe should be place in your local drive or path
System.setProperty("webdriver.chrome.driver", 
"C://Selenium//chromedriver.exe");

//launch facebook website 
driver.get("https://www.facebook.com");   

//Finding the Element using 'id' attribute and Enter 
//the Login credentials for user id and password using
driver.findElement(By.id("email")).sendKeys("xxxxxxxx@gmail.com");   
driver.findElement(By.id("pass")).sendKeys("xxxxxx@123");  
 
 //Click login button
 driver.findElement(By.id("loginbutton")).click();

//Implicit time to wait for 10 seconds 
 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
 
 //Maximizing the browser
 driver.manage().window().maximize();

 //close the browser if you want
 //driver.close();
Socialize It and Share the post with your friends
SOCIALIZE IT →
FOLLOW US →
SHARE IT →