
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Automate Gmail Login Process Using Selenium WebDriver in Java
We can automate the Gmail login process using Selenium webdriver in Java. To perform this task, first we have to launch the Gmail login page and locate the email, password and other elements with the findElement method and then perform actions on them.
Let us have the look at the Gmail login page −
Code Implementation
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; public class GmailLogin{ public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\Users\ghs6kor\Desktop\Java\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); //implicit wait driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS); //URL launch driver.get("https://accounts.google.com/signin"); //identify email WebElement l = driver .findElement(By.name("identifier")); l.sendKeys("abc@gmail.com"); WebElement b = driver .findElement(By.className("VfPpkd-LgbsSe")); b.click(); //identify password WebElement p = driver .findElement(By.name("password")); p.sendKeys("123456"); b.click(); //close browser driver.close(); } }
Advertisements