100% found this document useful (1 vote)
348 views

Software Testing Lab Manual

The document provides instructions for software testing experiments to be conducted using Selenium IDE and Selenium WebDriver. It lists the softwares to be used, marks distribution details for continuous internal evaluation and semester end examination, and 12 experiments divided into Part A involving record and playback of test cases using Selenium IDE and Part B involving automation of test scenarios using Selenium WebDriver scripts. It gives the objectives, steps and expected results for each experiment.

Uploaded by

vibhav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
348 views

Software Testing Lab Manual

The document provides instructions for software testing experiments to be conducted using Selenium IDE and Selenium WebDriver. It lists the softwares to be used, marks distribution details for continuous internal evaluation and semester end examination, and 12 experiments divided into Part A involving record and playback of test cases using Selenium IDE and Part B involving automation of test scenarios using Selenium WebDriver scripts. It gives the objectives, steps and expected results for each experiment.

Uploaded by

vibhav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Department of Computer Science and

Engineering

Laboratory Manual

Software Testing
16CS601
(2018 - 2019)

NMAM INSTITUTE OF TECHNOLOGY


(An Autonomous Institution affiliated to VTU, Belgaum)
(NBA Accredited, ISO 9001:2008 Certified)
Nitte – 574110, Karkala, Udupi District, Karnataka, India
Software Testing
16CS601

Softwares used
1. Ubuntu 16.04
2. Selenium IDE
3. Eclipse IDE
4. Geckodriver
5. Selenium-java-jar files
6. Mozilla firefox browser

Marks distribution:
CIE Marks Distribution

Assessment Weight-age in Marks


Continuous evaluation 30
MSE 20
Total 50

MSE Marks Distribution:

Evaluation Distribution of Marks


Execution of Part A program 5
Write-up and Execution of Part B program 5+5
Viva voce 5
Total 20

1
SEE Marks Distribution:

Evaluation Distribution of Marks


Write-up and Execution of Part A program 5 + 10
Write-up and Execution of Part B program 10 + 15
Viva voce 10
Total 50

Prepared by:
Krishnaraj
Sandeep Hegde
Shabari Shetty
Rajalaxmi Hegde

2
List of Experiments

Part A

Sl. Page
Experiment
No. No.
Open flipkart.com and locate element using name and xpath. For the same
1 write a test suite containing minimum 3 test cases using IDE record and 5
playback
Open airasia.com search flight process to automate and locate web element
2 using id. For the same write a test suite containing minimum 3 test cases using 7
IDE record and playback
Open google.co.in and search for some item and locate element by name and
3 id for the same write a test suite containing minimum 3 test cases using IDE 9
record and playback
Open facebook.com and record login and logout and locate element using
4 xpath. For the same, write a test suite containing minimum 3 test cases using 11
IDE record and playback
Open snapdeal.com and search for any web element using name. For the same
5 write a test suite containing minimum of 3 test cases using IDE record and 15
playback
Open Mercury Tours homepage and locate web element using xpath. For the
6 same write a test suite containing minimum 3 test cases using IDE record and 16
play back

3
Part B

Sl. Page
Experiment
No. No.
Automate the following scenario using selenium web driver script.
• Fetch Mercury Tour’s homepage.
1 • Verify its title. 19
• Print out the result of the comparison.
• Close it before ending the entire program.
Automate the following scenario using selenium web driver script.
• Launch the browser and open “Gmail.com”.
• Verify the title of the page and print the verification result.
2 20
• Enter the username and password.
• Click on the Sign in button.
• Close the web browser.
Automate the following scenario using selenium web driver script.
• Launch the Firefox browser.
• Open website, “https://www.flipkart.com”.
3 21
• Print message to display that the website is opened successfully.
• Wait for 5 seconds.
• Close the browser.

4
PART A

Q1. Open flipkart.com and locate element using name and xpath. For the same write a test
suite containing minimum 3 test cases using IDE record and playback.

1) Verifying the presence of ‘Search Bar’:

Command Target Value


open https://www.flipkart.com
set window size 1500x850
verify element present name=q
click name=q
type name=q Mobiles
click xpath=//button[@type='submit']

Log:
Running ‘Search Bar’
1. open on https://www.flipkart.com ...OK
2. setWindowSize on 1500x850 …OK
3. verifyElementPresent on name=q …OK
4. click on name=q…OK
5. type on name=q with value=Mobiles …OK
6. click on xpath=//button[@type='submit'] …OK
‘Search Bar’ completed successfully

2) Verifying the presence of ‘Search Button’:

Command Target Value


open https://www.flipkart.com
set window size 1500x850
click name=q
type name=q Laptops
verify element present xpath=//button[@type='submit']
click xpath=//button[@type='submit']

5
Log:
Running ‘Search Button’
1. open on https://www.flipkart.com …OK
2. setWindowSize on 1500x850 …OK
3. click on name=q …OK
4. type on name=q with value=Laptops OK
5. verifyElementPresent on xpath=//button[@type='submit'] …OK
6. click on xpath=//button[@type='submit'] …OK
‘Search Button’ completed successfully

3) Verifying redirection from ‘Login Page’:

Command Target Value


open https://www.flipkart.com
set window size 1500x850
click linkText=Login & Signup
verify element present xpath=//div[2]/div/div/div/div/div[2]/div/form/div/input
click xpath=//div[2]/div/div/div/div/div[2]/div/form/div/input
type xpath=//div[2]/div/div/div/div/div[2]/div/form/div/input [email protected]
click xpath=//div[2]/button
click xpath=//button[2]
click xpath=//div[2]/input
type xpath=//div[2]/input abc
click xpath=//div[3]/button

Log:
Running ‘Login Page’
1. open onhttps://www.flipkart.com ...OK
2. setWindowSize on 1107x710 …OK
3. click on linkText=Login & Signup …OK
4. verifyElementPresent on xpath=//div[2]/div/div/div/div/div[2]/div/form/div/input …OK
5. click on xpath=//div[2]/div/div/div/div/div[2]/div/form/div/input …OK
6. type on xpath=//div[2]/div/div/div/div/div[2]/div/form/div/input with value
[email protected] …OK
7. click on xpath=//div[2]/button …OK
8. Trying to find xpath=//button[2] …OK
9. click on xpath=//div[2]/input …OK

6
10. type on xpath=//div[2]/input with value abc…OK
11. click on xpath=//div[3]/button …OK
‘Login Page’ completed successfully

Q2. Open airasia.com search flight process to automate and locate web element using id. For
the same write a test suite containing minimum 3 test cases using IDE record and playback.

1) Verifying the presence of ‘Origin’ field:

Command Target Value

open https://www.airasia.com

set window size 1463x824

verify element present id=home-origin-autocomplete-heatmap

click id=home-origin-autocomplete-heatmap

type id=home-origin-autocomplete-heatmap Goa (GOI)

click id=home-destination-autocomplete-heatmap

type id=home-destination-autocomplete-heatmap Bengaluru (BLR)

Log:
Running ‘Origin’
1. Open on/booking/home/en/gb …OK
2. setWindowSize on 1463x824 …OK
3. verifyElementPresent on id=home-origin-autocomplete-heatmap …OK
4. click on id=home-origin-autocomplete-heatmap …OK
5. type on id =home-origin-autocomplete-heatmap with value Goa (GOI) …OK
6. click on id=home-destination-autocomplete-heatmap …OK
7. type on id=home-destination-autocomplete-heatmap with value Bengaluru (BLR) …OK
‘Origin’ completed successfully

2)Verifying the presence of ‘Destination’ field:

7
Command Target Value

open https://www.airasia.com

set window size 1463x824

click id=home-origin-autocomplete-heatmap

type id=home-origin-autocomplete-heatmap Goa (GOI)

verify element present id=home-destination-autocomplete-heatmap

click id=home-destination-autocomplete-heatmap

type id=home-destination-autocomplete-heatmap Bengaluru (BLR)

Log:
Running ‘Destination’
1. Open on/booking/home/en/gb …OK
2. setWindowSize on 1463x824 …OK
3. click on id=home-origin-autocomplete-heatmap …OK
4. type on id =home-origin-autocomplete-heatmap with value Goa (GOI) …OK
5. verifyElementPresent on id=home-destination-autocomplete-heatmap …OK
6. click on id=home-destination-autocomplete-heatmap …OK
7. type on id=home-destination-autocomplete-heatmap with value Bengaluru (BLR) …OK

‘Destination’ completed successfully

3)Verifying the presence of ‘Search’ button:

Command Target Value

open https://www.airasia.com

set window size 1463x824

click id=home-origin-autocomplete-heatmap

type id=home-origin-autocomplete-heatmap Dhaka(DAC)

8
click id=home-destination-autocomplete-heatmap

type id=home-destination-autocomplete-heatmap Sydney(SAN)

verify element present id=home-flight-search-airasia-button-inner-button-select-


flight-heatmap
click id=home-flight-search-airasia-button-inner-button-select-
flight-heatmap

Log:
Running ‘Search’
1. Open on /booking/home/en/gb …OK
2. setWindowSize on 1463x824 …OK
3. click on id=home-origin-autocomplete-heatmap…OK
4. type on id =home-origin-autocomplete-heatmap with value Dhaka(DAC)…OK
5. click on id=home-destination-autocomplete-heatmap…OK
6. type on id=home-destination-autocomplete-heatmap with value Sydney(SAN) …OK
7. verifyElementPresent on id=home-flight-search-airasia-button-inner-button-select-flight-
heatmap …OK
8. click on id=home-flight-search-airasia-button-inner-button-select-flight-heatmap…OK

‘Search’ completed successfully

Q3. Open google.co.in and search for some item and locate element by name and id for the
same write a test suite containing minimum 3 test cases using IDE record and playback.

1) Verifying the presence of search bar:

Command Target Value


Open https://www.google.co.in
set window size 710x713
verify element present name=q
Click name=q
Type name=q mobiles
Click name=btnK

Log:
Running ‘searchBar’

9
1. open on https://www.google.com.in…OK
2. setWindowSize on 710x713 …OK
3. verifyElementPresent on name=q …OK
4. click on name=q …OK
5. type on name=q with value mobiles …OK
6. click on name=btnK...OK
‘searchBar’ completed successfully

2) Verifying the presence of Search Button:

Command Target Value


Open https://www.google.co.in
Set Window size 1529*876
Click Name=q
Type Name=q Selenium
Verify element present Name=btnk
Click Name=btnk
Verify title Selenium-Google Search

Log:
Running ‘searchButton’
1. Open on https://www.google.co.in…OK
2. setWindowSize on 1529*876 …OK
3. click on name=q …OK
4. type on name=q with value Selenium …OK
5. verifyElementPresent on name=btnk…OK
6. click on name=btnk…OK
7. verifyTitle on Selenium-Google Search …OK
‘searchButton’ completed successfully.

3) Verifyingthe presence of ‘Email Id’ field:

Command Target Value


open https://www.google.co.in
set window size 1366x728
click linkText=Sign in
verify title Sign in - Google Accounts
verify element present id=identifierId
click id=identifierId

10
Log:
Running ‘Email Id Field’
1.open on https://www.google.co.in/ OK
2.setWindowSize on 1529x876 OK
3.click on linkText=Sign in OK
4.verifyTitle on Sign in - Google Accounts OK
5.verifyElementPresent on id=identifierId OK
6.click on id=identifierId OK
‘Email Id Field’ completed successfully.

Q4. Open facebook.com and record login and logout and locate element using xpath. For
the same, write a test suite containing minimum 3 test cases using IDE record and playback.

1) Verifying the presence of element ‘Email’ field:

Command Target Value

open https://www.facebook.com/

set window size 1529 x 876

verify element present xpath = //input[@id = “email”]

click xpath = //input[@id = “email”]

type xpath = //input[@id = “email”] [email protected]

click xpath = //input[@id =“pass”]

type xpath = //input[@id = “pass”] password

click id=u_0_3

pause 5000

click xpath =
//a[@id='pageLoginAnchor']/div
pause 2000

11
click xpath = //li[contains(.,'Log Out')]

Logs:
Running ‘Email field test’
1. open on https://www.facebook.com/ ...OK
2. setWindowSize on 1529x876 …OK
3. verifyElementPresent on xpath = //input[@id = “email”] …OK
4. click on xpath = //input[@id = “email”] …OK
5. type on xpath = //input[@id = “email”] with value [email protected] ...OK
6. click on xpath = //input[@id = “pass”] …OK
7. type on xpath = //input[@id = “pass”] with value password …OK
8. click on id = u_0_3 …OK
9. pause on 5000 ...OK
10. click on xpath = //a[@id='pageLoginAnchor']/div ...OK
11. pause on 2000 ...OK
12. click on xpath = //li[contains(.,'Log Out')] ...OK
‘Email field test’ completed successfully

2)Verifying the presence of ‘Log Out’ link:

Command Target Value

open https://www.facebook.com/

set window size 1529 x 876

click xpath = //input[@id = “email”]

type xpath = //input[@id = “email”] [email protected]

click xpath = //input[@id = “pass”]

type xpath = //input[@id = “pass”] password

send keys xpath = //input[@id = “pass”] ${KEY_ENTER}

pause 5000

12
click xpath = //a[@id='pageLoginAnchor']/div

pause 2000

verify element present xpath = //li[contains(.,'Log Out')]

click xpath = //li[contains(.,'Log Out')]

Logs:
Running ‘Log Out link test’
1. open on https://www.facebook.com/ ...OK
2. setWindowSize on 1529x876 ...OK
3. click on xpath = //input[@id = “email”] ...OK.
4. type on xpath = //input[@id = “email”] with value [email protected] ...OK
5. click on xpath = //input[@id = “pass”] ...OK
6. type on xpath = //input[@id = “pass”] with value password ...OK
7. sendKeys on xpath = //input[@id = “pass”] with value ${KEY_ENTER} ...OK
8. pause on 5000 ...OK
9. click on xpath = //a[@id='pageLoginAnchor']/div ...OK
10. pause on 2000 ...OK
11. verifyElementPresent on xpath = //li[contains(.,'Log Out')] ...OK
12. click on xpath = //li[contains(.,'Log Out')] ...OK
‘Log Out link test’ completed successfully

3) Verifying the presence of ‘Facebook Home’ button:

Command Target Value

open https://www.facebook.com/

set window size 1529 x 876

click xpath = //input[@id = “email”]

type xpath = //input[@id = “email”] [email protected]

click xpath = //input[@id = “pass”]

13
type xpath = //input[@id = “pass”] password

pause 5000

click id=u_0_3

verify element present linkText=Home

click linkText=Home

click id=userNavigationLabel

click css=.\_64kz .\_54nh

click xpath = //a[@id='pageLoginAnchor']/div

pause 2000

click xpath = //li[contains(.,'Log Out')]

Logs:
Running ‘Home Button verification test’
1. open on https://www.facebook.com/ OK
2. setWindowSize on 1529x876 OK
3. click on xpath=//input[@id='email'] OK
4. type on xpath=//input[@id='email'] with value [email protected] OK
5. click on xpath=//input[@id='pass'] OK
6. type on xpath=//input[@id='pass'] with value password OK
7. pause with value 3000 OK
8. click on id=u_0_2 OK
9. verifyElementPresent on linkText=Home OK
10. click on linkText=Home OK
11. click on id=userNavigationLabel OK
12. Trying to find css=.\_64kz .\_54nh... OK
13. click on xpath = //a[@id='pageLoginAnchor']/div ...OK
14. pause on 2000 ...OK
15. click on xpath = //li[contains(.,'Log Out')] ...OK
‘Home Button verification test’ completed successfully

14
Q5. Open snapdeal.com and search for any web element using name. For the same write a
test suite containing minimum of 3 test cases using IDE record and playback.

1) Verifying the presence of ‘Search field’:

Command Target Value


open https://www.snapdeal.com/
set window size 1529x876
verify element present name=keyword
click name=keyword

Log:
Running ‘Search Field'
1. open on https://www.snapdeal.com/ …OK
2. setWindowSize on 1529x876 …OK
3. verifyElementPresent on name=keyword …OK
4. click on name=keyword …OK
‘Search Field’ completed successfully
2) Verifying the presence of ‘Login field’:

Command Target Value


open https://www.snapdeal.com/
set window size 1529x876
click css=.accountUserName
click css=.accountBtn:nth-child(3)
select frame index=3
verify element present name=username
click name=username

Log:
Running ‘Login Field’
1.open on https://www.snapdeal.com/ …OK
2.setWindowSize on 1382x754 …OK
3.click on css=.accountUserName…OK
4.click on css=.accountBtn:nth-child(3) …OK
5.selectFrame on index=3 …OK
6.verifyElementPresent on name=username …OK
7.click on name=username …OK
‘Login Field’ completed successfully

15
3) Verifying the presence of ‘Help Search field’ under help center page:

Command Target Value


open https://www.snapdeal.com/
set window size 1529x876
click linkText=Help Center
verify title Snapdeal : Help Center
verify element present name=faq_search_text
click name=faq_search_text

Log:
Running ‘Help Search Field’
1.open on https://www.snapdeal.com/ …OK
2.setWindowSize on 1529x876...OK
3.click on linkText=Help Center...OK
4.verifyTitle on Snapdeal : Help Centre...OK
5.verifyElementPresent on name=faq_search_text...OK
6.click on name=faq_search_text …OK
‘Help Search Field’ completed successfully

Q6. Open Mercury Tours homepage and locate web element using xpath. For the same write
a test suite containing minimum 3 test cases using IDE record and play back.

1) Verifying the presences of ‘Our Coaches’ link and its functionality:

Command Target Value


open http://mercury-tours.com
set window size 1463x824
verify element present xpath=//a[2]/span
click xpath=//a[2]/span

Log:
Running ‘Our coaches’
1. open on http://mercury-tours.com …OK
2. setWindowSize on 1463x824 …OK

16
3. verifyElementPresent on xpath=//a[2]/span …OK
4. click on xpath=//a[2]/span …OK
'Our Coaches' completed successfully

2) Verifying the presence of ‘Contact Us’ link and returning to Home page from Contact us page:

Command Target Value


open http://mercury-tours.com
set window size 1463x824
verify element present xpath=//a[3]/span
click xpath=//a[3]/span
verify element present xpath=//a/span
click xpath=//a/span

Log:
Running ‘Contact us and Back to home’
1. open on http://mercury-tours.com ...OK
2. setWindowSize on 1463x824 …OK
3. verifyElementPresent on xpath=//a[3]/span …OK
4. click on xpath=//a[3]/span …OK
5. verifyElementPresent on xpath=//a/span …OK
6. click on xpath=//a/span …OK
‘Contact us and Back to home’ completed successfully

3) Verifying the presence of ‘Specialized Tours’ link and its functionality:

Command Target Value


open http://www.mercury-tours.com
set window size 1463x824
verify element present xpath=//a[5]/span
click xpath=//a[5]/span
click linkText=More Of Where We Go....
verify text id=Welcome_Bar Where We go...
verify title Mercury Tours Where We Go Page

Log:
Running ‘Specialized Tours’
1. open on http://mercury-tours.com…OK

17
2. setWindowSize on 1463x824 …OK
3. verifyElementPresent on xpath=//a[5]/span …OK
4. click on xpath=//a[5]/span …OK
5. click on linkText=More Of Where We Go.... …OK
6. verifyText on id=Welcome_Bar with value Where We go... …OK
7. verifyTitle on Mercury Tours Where We Go Page …OK
‘Specialized Tours’ completed successfully

PART B

Q1. Automate the following scenario using selenium web driver script.

18
• Fetch Mercury Tour’s homepage.
• Verify its title.
• Print out the result of the comparison.
• Close it before ending the entire program.

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import java.util.Scanner;
public class Demo {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.setProperty("webdriver.gecko.driver","/home/student/selenium/geckodriver");

System.out.print("Enter expected title:");


String expected = sc.nextLine(); // Welcome: Mercury Tours

String url = "http://demo.guru99.com/test/newtours/";

WebDriver driver = new FirefoxDriver();


driver.get(url);
if(driver.getTitle().equals(expected)) {
System.out.println("Test Passed:Title match");
}
else {
System.out.println("Test Failed:Title mismatch.");
}
driver.close();
}
}

Output:
Case 1:
Enter expected title:Welcome: Mercury Tours
Test Passed:Title match

Case 2:
Enter expected title:Welcome
Test Failed:Title mismatch.

Q2. Automate the following scenario using selenium web driver script.

19
• Launch the browser and open “Gmail.com”.
• Verify the title of the page and print the verification result.
• Enter the username and password.
• Click on the Sign in button.
• Close the web browser.

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import java.util.Scanner;
public class MyClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "/home/student/selenium/geckodriver");
Scanner sc = new Scanner(System.in);
String baseUrl = "https://www.gmail.com";

System.out.print("Enter expected title:"); // Gmail


String expected = sc.nextLine();
WebDriver driver = new FirefoxDriver();
driver.get(baseUrl);
if(driver.getTitle().equals(expected))
{
System.out.println("Test Passed:Title Matched");
driver.findElement(By.id("identifierId")).clear();
driver.findElement(By.id("identifierId")).sendKeys("[email protected]");
driver.findElement(By.id("identifierNext")).click();
try {
Thread.sleep(5000);
}
catch(Exception e)
{
System.out.println("Exception occured.");
}
driver.findElement(By.name("password")).sendKeys("password");
driver.findElement(By.id("passwordNext")).click();

}
else System.out.println("Test Failed:Title Mismatch");
driver.close();
}

20
}

Output:
Case 1:
Enter expected title:Gmail
Test Passed:Title Matched

Case 2:
Enter expected title:Facebook
Test Failed:Title Mismatch

Q3. Automate the following scenario using selenium web driver script.
• Launch the Firefox browser.
• Open website, “https://www.flipkart.com”.
• Print message to display that the website is opened successfully.
• Wait for 5 seconds.
• Close the browser.

import org.openqa.selenium.*;
import org.openqa.selenium.firefox.*;
import java.util.Scanner;
public class MyClass {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.setProperty("webdriver.gecko.driver","/home/student/selenium/geckodriver");
System.out.print("Enter url:");
String url = sc.nextLine(); // https://www.flipkart.com
String expected = "Online Shopping Site for Mobiles, Electronics, Furniture, Grocery,
Lifestyle, Books & More. Best Offers!";

WebDriver driver = new FirefoxDriver();


driver.get(url);
if(driver.getTitle().equals(expected)) {
System.out.println("Test Passed:Web page loaded successfully");
}
else {
System.out.println("Test Failed:Web page title mismatch.");
}
System.out.println("Waiting 5 seconds....");

21
try {
Thread.sleep(5000);
}
catch(InterruptedException e)
{
System.out.println(e);
}
driver.close();
System.out.println("Web browser closed.");
}
}

Output:
Case 1:
Enter url:https://www.flipkart.com
Test Passed:Web page loaded successfully
Waiting 5 seconds....
Web browser closed.

Case 2:
Enter url:https://www.facebook.com
Test Failed:Web page title mismatch.
Waiting 5 seconds....
Web browser closed.

22

You might also like