Testing beyond limits!

Search This Blog

Wednesday, October 28, 2015

Login to Gmail using Selenium Webdriver

If you have just started with Selenium and struggling with creating and executing your first test case, here's a script to Login to Gmail using Selenium Webdriver.

Once you Login to Gmail using Selenium Webdriver you will get enough confidence to move on further and automate whatever you like:

Here's the code to automate Login to Gmail using Selenium Webdriver:

package automationFramework;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class FirstTestCase {

    public static void main(String[] args) throws Exception {
        // Create a new instance of the Firefox driver
        WebDriver driver = new ChromeDriver();
        //Launch the Online Store Website

        // Print a Log In message to the screen
        System.out.println("Successfully opened the website gmail.com");

        //Wait for 5 Sec
        //Maximize window
        //Enter Username
        //Click on Next
        // Wait For Page To Load
        driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
        //Enter Password
        // Click on 'Sign In' button
        // Close the driver