Selenium
​
​
​
Selenium WebDriver Installation And Setup
​
​
​
​
​
​
​
​
Handling Radio Buttons And CheckBoxes
​
​
​
​
Gmail Automation Example
​
​
Here is the example of gmail Automation , you will learn how to automate gmail account. Creating a java selenium script to login into gmail account
Here are some steps , please follow
Step-1
​
Launch gmail website in browser and find 'SIGN IN' button , click on this button by selenium web driver.
![](https://static.wixstatic.com/media/3bc9da_57eb324d6b824b139182aa4dc2e5bcb2~mv2.png/v1/fill/w_386,h_95,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/3bc9da_57eb324d6b824b139182aa4dc2e5bcb2~mv2.png)
​
​
​
Step-2
Here we will provide email/phone and click on NEXT button.
![](https://static.wixstatic.com/media/3bc9da_657df0a6aad94c13b62b75d7978c3c16~mv2.png/v1/fill/w_449,h_406,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/3bc9da_657df0a6aad94c13b62b75d7978c3c16~mv2.png)
Step-3
Now we will provide Password and click on NEXT button
​
![](https://static.wixstatic.com/media/3bc9da_3d942d4026d1478e876d9b82b76a7cfc~mv2.png/v1/fill/w_434,h_459,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/3bc9da_3d942d4026d1478e876d9b82b76a7cfc~mv2.png)
Finally Logged into Gmail Account
​
Here is final code =>
​
package com.alok.seleniumTutorials;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class LoginIntoGmail {
public static void main(String[] args) throws InterruptedException {
// ChromeDriver path
System.setProperty("webdriver.chrome.driver", "drivers/chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseurl = "https://www.google.com/gmail/about/#";
System.out.println("Opening 'Gmail' on chrome browser");
driver.get(baseurl);
// click on Sign In button
WebElement signIn =driver.findElement(By.xpath("//a[text()='Sign In']"));
signIn.click();
Thread.sleep(1000);
// Enter UserName Value and click On Next Button
WebElement userName =driver.findElement(By.xpath("//input[@type='email']"));
userName.clear();
userName.sendKeys("Your Gmail User Name/Phone Number");
WebElement nextButton =driver.findElement(By.xpath("//span[text()='Next']"));
nextButton.click();
Thread.sleep(1000);
// Enter Password Value and click On Next Button
WebElement userPassword =driver.findElement(By.xpath("//input[@type='password']"));
userPassword.clear();
userPassword.sendKeys(" Your Gmail Password");
Thread.sleep(1000);
WebElement nextButton1 =driver.findElement(By.xpath("//span[text()='Next']"));
nextButton1.click();
Thread.sleep(8000);
System.out.println("Waiting for 8 sec");
driver.close();
System.out.println("closed chorme browser");
// LogOut From Gmail
WebElement userProfile = driver.findElement(By.xpath("//a[contains(@href,'SignOutOptions') and @role='button']"));
userProfile.click();
Thread.sleep(3000);
System.out.println("User clicked profile button");
WebElement signout = driver.findElement(By.xpath("//a[contains(@href,'Logout') and text()='Sign out']"));
signout.click();
System.out.println("User clicked signout button");
driver.close();
System.out.println("closed chorme browser");
}
}
​
​
Refer next page Handling Drop-Downs