webdriver exam cases

Selenium WebDriver Sample Test Case
--------------------------------------------------- 
Operating Environment: MS Windows

Programming Language: Java

IDE: Eclipse:
------------------------
WebDriver Environment Setup: 

---------------------------------------------------
> Download in addition to Java (JDK) in addition to Install

> Set Path Variable (Environment Variable)

> Download EClipse Software

> Download WebDriver Java Language Binding in addition to Add WebDriver Jars to Java Project
in Eclipse

> Download in addition to Install Firebug (As Firefox Browser Plug in)
(If nosotros desire purpose IE or Chrome browsers, no postulate to download whatever plug in, they accept their ain developer tools to inspect elements.)

> Download Internet Explorer in addition to Chrome Drivers for WebDriver.

---------------------------------------------------
Write Influenza A virus subtype H5N1 Sample Test:


 > Launch EClipse IDE

> Create coffee Project

> Create Package

> Create Class in addition to write Test/Program

---------------------------------------------------
 How to Write: 
---------------------------------------------------
 > Import WebDriver Libraries in addition to Browser (Ex: Firefox) driver libraries.

> Create Driver Object

> Inspect Elements using Firebug for Firefox browser.

> Write Test using Element locators in addition to WebDriver Methods.
-----------------------------------------------------------------
Note: WebDriver Methods in addition to Web chemical ingredient locators are mutual for all Browsers.
 
---------------------------------------------------
 Create a Test for Gmail Login Functionality:
Steps:
i) Launch the Browser
ii) Navigate to Gmail domicile page
iii) Enter Email
iv) Enter Password
v) Click Sign In Button
---------------------------------
a) Test for Firefox Browser:

-----------------------------
package WebDriverTests;

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

public cast GmailLogin {
    world static void main(String [] args) throws InterruptedException {
        WebDriver driver = novel FirefoxDriver();
        driver.get("http://gmail.com");
        driver.findElement(By.id("Email")).sendKeys("gcreddy123");
        driver.findElement(By.id("Passwd")).sendKeys("selenium123");
        driver.findElement(By.id("signIn")).click();
        Thread.sleep(10000);
        String Expected ="inbox";
        String URLTitle = driver.getCurrentUrl();
        if (URLTitle.contains(Expected)){
            System.out.println("Login Successful");
        }
            else{
                System.out.println("Login Failed");   
            }
            }
    }
-------------------------------------------------------
a) Test for Internet Explorer Browser:
package WebDriverTests;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public cast GmailLogin {
    world static void main(String [] args) throws InterruptedException {
        System.setProperty("webdriver.ie.driver", "d://IEDriverServer.exe");
        WebDriver driver = novel InternetExplorerDriver();
        driver.get("http://gmail.com");
        driver.findElement(By.id("Email")).sendKeys("gcreddy123");
        driver.findElement(By.id("Passwd")).sendKeys("selenium123");
        driver.findElement(By.id("signIn")).click();
        Thread.sleep(10000);
        String Expected ="inbox";
        String URLTitle = driver.getCurrentUrl();
        if (URLTitle.contains(Expected)){
            System.out.println("Login Successful");
        }
            else{
                System.out.println("Login Failed");   
            }
            }
    }
---------------------------------------------------------
c) Test for Chrome Browser
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public cast GmailLogin {
    world static void main(String [] args) throws InterruptedException {
        System.setProperty("webdriver.chrome.driver", "d://chromeDriver.exe");
        WebDriver driver = novel ChromeDriver();
        driver.get("http://gmail.com");
        driver.findElement(By.id("Email")).sendKeys("gcreddy123");
        driver.findElement(By.id("Passwd")).sendKeys("selenium123");
        driver.findElement(By.id("signIn")).click();
        Thread.sleep(10000);
        String Expected ="inbox";
        String URLTitle = driver.getCurrentUrl();
        if (URLTitle.contains(Expected)){
            System.out.println("Login Successful");
        }
            else{
                System.out.println("Login Failed");   
            }
            }
    }
----------------------------------------------------------

Sumber http://www.gcreddy.com/
Post a Comment (0)
Previous Post Next Post