Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a automation End-to-End integration test case using Selenium Web Driver J

ID: 667011 • Letter: C

Question

Create a automation End-to-End integration test case using Selenium Web Driver Junit 4.
choosing from following domains Any One:

(1) E-Commerce - Amazon, eBay, TOYOTA
(2) Financials - Bank of America
(3) Internet Service Provider - Yahoo, Google
(4) Social Media - Facebook, LinkedIn, Twitter
(5) Cloud Computing - Salesforce
(6) Health Care - Covered California

End to End use case example:
Rajesh opens NPU web page, goes through the main home page
Open Admissions to check some quick links
Open Academics to learn more details
Open Campus and go through NPU Campus tour
Check more information (e.g. News and Blogs)
Go to Online Application to register

End to End use case example 2:
Open Amzon.com
Search a item you want to buy
Select a search result and open it
Check the details (Price, color, accessory etc.) to compare if they are expected
Put in shopping cart
Add another one or update the previous item, check total price and verify delivery schedule.

Requirement:
1) The End to End use case should have detailed steps what to do, more than 10 steps to cover a completed User story.
2) put the test case steps in the beginning of the test case (class) with Java Doc format
/*
**
* 1. Open Amazon.com
* 2. Input iWatch and select iWatch Apple in the drop down menu, open it
* 3. Compare price, if it is less than $500, continue to check other accessories
* 4. ....
*/

You should also put each step as comment before the automation scrip
// 1. Open Amazon.com
driver.get("http://amazon.com");

// 2. Input iWatch and select iWatch Apple in the drop down menu, open it
driver.FindElement(By.id("twotabsearchtextbox")).sendKeys("iWatch"); // input
Actions action = new Actions(driver);
action.sendKeys(Keys.DOWN).build().perform(); // move Down key
action.sendKeys(Keys.DOWN).build().perform(); // move Down key
action.sendKeys(Keys.DOWN).build().perform(); // move Down key
action.sendKeys(Keys.DOWN).build().perform(); // move Down key
action.sendKeys(Keys.ENTER).build().perform(); // hit Enter key to open
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); // wait
this.sleep(1);

Explanation / Answer

Ans:

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.testng.Assert;

import org.testng.annotations.BeforeClass;

import org.testng.annotations.Test;

import org.testng.annotations.AfterClass;

public class TestClass1

{

protected static WebDriver wd;

            protected static String result;

            @BeforeClass

public static void setup()

{

            wd = new FirefoxDriver();

            wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

}

            @Test

void Testcase1()

{

            wd.findElement(By.id("kwsch")).sendKeys("Red");

            wd.findElement(By.xpath("//input[@src='images/go.gif']")).click();

            result = wd.findElement(By.xpath("//font[text()='Total Items :']//following::td[1]")).getText();

Assert.assertEquals(result, "115");

}

            @Test

void Testcase2() {

            wd.findElement(By.id("kwsch")).sendKeys("Blue");

            wd.findElement(By.xpath("//input[@src='images/go.gif']")).click();

            result = wd.findElement(By.xpath("//font[text()='Total Items :']//following::td[1]")).getText();

            Assert.assertEquals(result, "13");

}

            @Test

void Testcase3() {

            wd.findElement(By.id("kwsch")).sendKeys("Yellow");

            wd.findElement(By.xpath("//input[@src='images/go.gif']")).click();

            result = wd.findElement(By.xpath("//font[text()='Total Items :']//following::td[1]")).getText();

            Assert.assertEquals(result, "27");

}

            @Test

void Testcase4() {

            wd.findElement(By.id("kwsch")).sendKeys("Purple");

            wd.findElement(By.xpath("//input[@src='images/go.gif']")).click();

            result = wd.findElement(By.xpath("//font[text()='Total Items :']//following::td[1]")).getText();

            Assert.assertEquals(result, "10");

}

@AfterClass

public static void teardown() {

            wd.close();

            wd.quit();

}

}

for testing in browser

for testing in browser

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.testng.Assert;

import org.testng.annotations.BeforeClass;

import org.testng.annotations.Test;

import org.testng.annotations.AfterClass;

public class TestClass1

{

protected static WebDriver wd;

            protected static String result;

            @BeforeClass

public static void setup()

{

            wd = new FirefoxDriver();

            wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

}

            @Test

void Testcase1()

{

            wd.findElement(By.id("kwsch")).sendKeys("Red");

            wd.findElement(By.xpath("//input[@src='images/go.gif']")).click();

            result = wd.findElement(By.xpath("//font[text()='Total Items :']//following::td[1]")).getText();

Assert.assertEquals(result, "115");

}

            @Test

void Testcase2() {

            wd.findElement(By.id("kwsch")).sendKeys("Blue");

            wd.findElement(By.xpath("//input[@src='images/go.gif']")).click();

            result = wd.findElement(By.xpath("//font[text()='Total Items :']//following::td[1]")).getText();

            Assert.assertEquals(result, "13");

}

            @Test

void Testcase3() {

            wd.findElement(By.id("kwsch")).sendKeys("Yellow");

            wd.findElement(By.xpath("//input[@src='images/go.gif']")).click();

            result = wd.findElement(By.xpath("//font[text()='Total Items :']//following::td[1]")).getText();

            Assert.assertEquals(result, "27");

}

            @Test

void Testcase4() {

            wd.findElement(By.id("kwsch")).sendKeys("Purple");

            wd.findElement(By.xpath("//input[@src='images/go.gif']")).click();

            result = wd.findElement(By.xpath("//font[text()='Total Items :']//following::td[1]")).getText();

            Assert.assertEquals(result, "10");

}

@AfterClass

public static void teardown() {

            wd.close();

            wd.quit();

}

}

for testing in browser

  @Test  
      public void testFirefox()  
              throws MalformedURLException, IOException {  
          DesiredCapabilities browser =  
              DesiredCapabilities.firefox();  
          testCodesCrud(browser);  
      }  
      @Test  
      public void testChrome()  
              throws MalformedURLException, IOException {  
          DesiredCapabilities browser =  
              DesiredCapabilities.chrome();  
          testCodesCrud(browser);  
      }  
       
      @Test  
      public void testOpera()  
              throws MalformedURLException, IOException {  
          DesiredCapabilities browser =  
              DesiredCapabilities.opera();  
          testCodesCrud(browser);