Writing Selenium WebDriver Test Cases Part -2
Writing Selenium WebDriver Test Cases
6) Test Case: Check Admin Login Functionality inward gcrShop spider web portal (Positive Test Case)
7) Test Case: Check Error Message/s inward Admin Login Functionality(Negative Test Case)
8) Test Case: Check Admin Functionality amongst valid in addition to invalid inputs(Positive in addition to Negative Testing)
-------------------------------------
6) Test Case: Check Admin Login Functionality inward gcrShop spider web portal (Positive Test Case)
Test Steps:
i) Launch the Browser
ii) Navigate to gcrShop Admin Interface (http://www.gcrit.com/build3/admin/)
iii) Enter Valid User name
iv) Enter Valid Password
v) Click "Login" Button
-------------------------
Verification Point:
Capture the url in addition to compare amongst expected.
Expected url:http://www.gcrit.com/build3/admin/index.php
Actual:
Test Data:
User mention = admin
Password = admin@123
-----------------------------------
Selenium Test Case:
WebDriver driver = novel FirefoxDriver();
driver.get("http://www.gcrit.com/build3/admin/");
driver.findElement(By.name("username")).sendKeys("admin");
driver.findElement(By.name("password")).sendKeys("admin@123");
driver.findElement(By.id("tdb1")).click();
String url = driver.getCurrentUrl();
if (url.equals("http://www.gcrit.com/build3/admin/index.php")){
System.out.println("Admin Login Successful - Passed");
}
else {
System.out.println("Admin Login Unsuccessful - Failed");
}
driver.close();
--------------------------------------
7) Test Case: Check Error Message/s inward Admin Login Functionality (Negative Test Case)
Test Steps:
i) Launch the Browser
ii) Navigate to gcrShop Admin Interface (http://www.gcrit.com/build3/admin/)
iii) Enter Invalid User mention in addition to / or Password
iv) Click "Login" Button
----------------------------
Verification point:
Capture the Error Message in addition to compare amongst expected.
Expected: Error: Invalid administrator login attempt.
Test Data:
User Name: admina
Password: admin@123
----------------------------------------------------
Selenium Test Case:
WebDriver driver = novel FirefoxDriver();
driver.get("http://www.gcrit.com/build3/admin/");
driver.findElement(By.name("username")).sendKeys("admina");
driver.findElement(By.name("password")).sendKeys("admin@123");
driver.findElement(By.id("tdb1")).click();
String url = driver.getCurrentUrl();
if (url.contains("http://www.gcrit.com/build3/admin/login.php")){
String ErrorMessage = driver.findElement(By.className("messageStackError")).getText();
if (ErrorMessage.contains("Invalid administrator login attempt.")){
System.out.println("Handling Invalid Inputs - Passed");
}
}
else {
System.out.println("Not Handling Invalid Inputs - Failed");
}
driver.close();
----------------------------------
Assignment:
Verify the maximum Login attempts (For invalid inputs only)
Verification: After 3 attempts it blocks the Login Functionality for v minutes.
----------------------------------------------
8) Test Case: Check Admin Functionality amongst valid in addition to invalid inputs (Positive in addition to Negative Testing)
Test steps:
i) Launch the Browser
ii) Navigate to gcrShop Admin Interface (http://www.gcrit.com/build3/admin/)
iii) Enter valid "User name"
iv) Enter Valid "Password"
v) Click "Login" Button
---------------
* Repeat the navigation amongst Invalid User Name in addition to / or Password
Verification points:
i) Capture the url in addition to compare amongst expected.
Expected: http://www.gcrit.com/build3/admin/index.php
Test Data:
User mention = admin
Password = admin@123
--------------
ii) Capture the Error message in addition to compare amongst expected:
Expected =Error: Invalid administrator login attempt.
Test Data:
User mention = admina
Password = admin@123a
(Invalid User mention in addition to Invalid Password)
Other Negative Scenarios:
1) Valid User mention in addition to Invalid Password
2) Invalid user Name in addition to Valid Password
3) Blank User mention in addition to Valid Password/Invalid Password
4) Valid / Invalid User mention in addition to Blank password
5) Blank User mention in addition to Blank password
-----------------------------------
Selenium Test Case:
public degree VerifyLogin {
static int i;
static String username, password, iteration;
public static void main(String[] args) throws InterruptedException {
WebDriver driver = novel FirefoxDriver();
for (i = 1; i <= 2; i++){
if (i == 1) {
username = "admin";
password = "admin@123";
iteration = "Iteration 1:";
}
else if(i == 2){
username = "admina";
password = "admin@123a";
iteration = "Iteration 2:";
}
driver.get("http://www.gcrit.com/build3/admin/");
driver.findElement(By.name("username")).sendKeys(username);
driver.findElement(By.name("password")).sendKeys(password);
Thread.sleep(3000);
driver.findElement(By.id("tdb1")).click();
String url = driver.getCurrentUrl();
if (url.contains("http://www.gcrit.com/build3/admin/index.php")){
System.out.println(iteration + ("Input Data: ") + username + ", "+ password + " Admin Login
Successful -Passed");
driver.findElement(By.linkText("Logoff")).click();
Thread.sleep(2000);
}
else if (! url.contains("http://www.gcrit.com/build3/admin/index.php")){
String ErrorMessage = driver.findElement(By.className("messageStackError")).getText();
if (ErrorMessage.contains("Invalid administrator login attempt.")){
System.out.println(iteration + ("Input Data: ") + username + ", "+ password + " Handling Invalid
Inputs -Passed");
}
else {
System.out.println(iteration + "- Failed");
}
}
}
driver.close();
}
}
---------------------------------------------
9) Test Case: Check communication betwixt unlike browsers.
Test Steps:
i) Create Mozilla Firefox driver, Google chrome driver in addition to IE driver.
ii) Launch 3 unlike applications
iii) Interact from 1 application to another
iv) Close all browsers 1 past times one.
-------------------------------------------
Selenium Test Case:
WebDriver firefoxDriver = novel FirefoxDriver();
firefoxDriver.get("https://www.google.com");
firefoxDriver.findElement(By.linkText("Gmail")).click();
String text = firefoxDriver.findElement(By.xpath("html/body/div[1]/div[2]/div[1]/h2")).getText();
System.setProperty("webdriver.chrome.driver", "E:\\chromedriver.exe");
WebDriver chromeDriver = novel ChromeDriver();
chromeDriver.get("http://www.gcrit.com/build3/create_account.php?
osCsid=1vbg1oj32ole3qrcv4b6mr7m24");
chromeDriver.findElement(By.name("firstname")).sendKeys(text);
Thread.sleep(3000);
System.setProperty("webdriver.ie.driver", "E:\\IEDriverServer.exe");
WebDriver IEDriver = novel InternetExplorerDriver();
IEDriver.get("https://in.mail.yahoo.com/");
firefoxDriver.close();
chromeDriver.close();
IEDriver.close();
-----------------------------------
Writing Selenium WebDriver Test Cases
6) Test Case: Check Admin Login Functionality inward gcrShop spider web portal (Positive Test Case)
7) Test Case: Check Error Message/s inward Admin Login Functionality(Negative Test Case)
8) Test Case: Check Admin Functionality amongst valid in addition to invalid inputs(Positive in addition to Negative Testing)
-------------------------------------
6) Test Case: Check Admin Login Functionality inward gcrShop spider web portal (Positive Test Case)
Test Steps:
i) Launch the Browser
ii) Navigate to gcrShop Admin Interface (http://www.gcrit.com/build3/admin/)
iii) Enter Valid User name
iv) Enter Valid Password
v) Click "Login" Button
-------------------------
Verification Point:
Capture the url in addition to compare amongst expected.
Expected url:http://www.gcrit.com/build3/admin/index.php
Actual:
Test Data:
User mention = admin
Password = admin@123
-----------------------------------
Selenium Test Case:
WebDriver driver = novel FirefoxDriver();
driver.get("http://www.gcrit.com/build3/admin/");
driver.findElement(By.name("username")).sendKeys("admin");
driver.findElement(By.name("password")).sendKeys("admin@123");
driver.findElement(By.id("tdb1")).click();
String url = driver.getCurrentUrl();
if (url.equals("http://www.gcrit.com/build3/admin/index.php")){
System.out.println("Admin Login Successful - Passed");
}
else {
System.out.println("Admin Login Unsuccessful - Failed");
}
driver.close();
--------------------------------------
7) Test Case: Check Error Message/s inward Admin Login Functionality (Negative Test Case)
Test Steps:
i) Launch the Browser
ii) Navigate to gcrShop Admin Interface (http://www.gcrit.com/build3/admin/)
iii) Enter Invalid User mention in addition to / or Password
iv) Click "Login" Button
----------------------------
Verification point:
Capture the Error Message in addition to compare amongst expected.
Expected: Error: Invalid administrator login attempt.
Test Data:
User Name: admina
Password: admin@123
----------------------------------------------------
Selenium Test Case:
WebDriver driver = novel FirefoxDriver();
driver.get("http://www.gcrit.com/build3/admin/");
driver.findElement(By.name("username")).sendKeys("admina");
driver.findElement(By.name("password")).sendKeys("admin@123");
driver.findElement(By.id("tdb1")).click();
String url = driver.getCurrentUrl();
if (url.contains("http://www.gcrit.com/build3/admin/login.php")){
String ErrorMessage = driver.findElement(By.className("messageStackError")).getText();
if (ErrorMessage.contains("Invalid administrator login attempt.")){
System.out.println("Handling Invalid Inputs - Passed");
}
}
else {
System.out.println("Not Handling Invalid Inputs - Failed");
}
driver.close();
----------------------------------
Assignment:
Verify the maximum Login attempts (For invalid inputs only)
Verification: After 3 attempts it blocks the Login Functionality for v minutes.
----------------------------------------------
8) Test Case: Check Admin Functionality amongst valid in addition to invalid inputs (Positive in addition to Negative Testing)
Test steps:
i) Launch the Browser
ii) Navigate to gcrShop Admin Interface (http://www.gcrit.com/build3/admin/)
iii) Enter valid "User name"
iv) Enter Valid "Password"
v) Click "Login" Button
---------------
* Repeat the navigation amongst Invalid User Name in addition to / or Password
Verification points:
i) Capture the url in addition to compare amongst expected.
Expected: http://www.gcrit.com/build3/admin/index.php
Test Data:
User mention = admin
Password = admin@123
--------------
ii) Capture the Error message in addition to compare amongst expected:
Expected =Error: Invalid administrator login attempt.
Test Data:
User mention = admina
Password = admin@123a
(Invalid User mention in addition to Invalid Password)
Other Negative Scenarios:
1) Valid User mention in addition to Invalid Password
2) Invalid user Name in addition to Valid Password
3) Blank User mention in addition to Valid Password/Invalid Password
4) Valid / Invalid User mention in addition to Blank password
5) Blank User mention in addition to Blank password
-----------------------------------
Selenium Test Case:
public degree VerifyLogin {
static int i;
static String username, password, iteration;
public static void main(String[] args) throws InterruptedException {
WebDriver driver = novel FirefoxDriver();
for (i = 1; i <= 2; i++){
if (i == 1) {
username = "admin";
password = "admin@123";
iteration = "Iteration 1:";
}
else if(i == 2){
username = "admina";
password = "admin@123a";
iteration = "Iteration 2:";
}
driver.get("http://www.gcrit.com/build3/admin/");
driver.findElement(By.name("username")).sendKeys(username);
driver.findElement(By.name("password")).sendKeys(password);
Thread.sleep(3000);
driver.findElement(By.id("tdb1")).click();
String url = driver.getCurrentUrl();
if (url.contains("http://www.gcrit.com/build3/admin/index.php")){
System.out.println(iteration + ("Input Data: ") + username + ", "+ password + " Admin Login
Successful -Passed");
driver.findElement(By.linkText("Logoff")).click();
Thread.sleep(2000);
}
else if (! url.contains("http://www.gcrit.com/build3/admin/index.php")){
String ErrorMessage = driver.findElement(By.className("messageStackError")).getText();
if (ErrorMessage.contains("Invalid administrator login attempt.")){
System.out.println(iteration + ("Input Data: ") + username + ", "+ password + " Handling Invalid
Inputs -Passed");
}
else {
System.out.println(iteration + "- Failed");
}
}
}
driver.close();
}
}
---------------------------------------------
9) Test Case: Check communication betwixt unlike browsers.
Test Steps:
i) Create Mozilla Firefox driver, Google chrome driver in addition to IE driver.
ii) Launch 3 unlike applications
iii) Interact from 1 application to another
iv) Close all browsers 1 past times one.
-------------------------------------------
Selenium Test Case:
WebDriver firefoxDriver = novel FirefoxDriver();
firefoxDriver.get("https://www.google.com");
firefoxDriver.findElement(By.linkText("Gmail")).click();
String text = firefoxDriver.findElement(By.xpath("html/body/div[1]/div[2]/div[1]/h2")).getText();
System.setProperty("webdriver.chrome.driver", "E:\\chromedriver.exe");
WebDriver chromeDriver = novel ChromeDriver();
chromeDriver.get("http://www.gcrit.com/build3/create_account.php?
osCsid=1vbg1oj32ole3qrcv4b6mr7m24");
chromeDriver.findElement(By.name("firstname")).sendKeys(text);
Thread.sleep(3000);
System.setProperty("webdriver.ie.driver", "E:\\IEDriverServer.exe");
WebDriver IEDriver = novel InternetExplorerDriver();
IEDriver.get("https://in.mail.yahoo.com/");
firefoxDriver.close();
chromeDriver.close();
IEDriver.close();
-----------------------------------