Software Testing Lab Manual
Software Testing Lab Manual
Engineering
Laboratory Manual
Software Testing
16CS601
(2018 - 2019)
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
1
SEE Marks Distribution:
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.
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
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
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.
open https://www.airasia.com
click id=home-origin-autocomplete-heatmap
click id=home-destination-autocomplete-heatmap
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
7
Command Target Value
open https://www.airasia.com
click id=home-origin-autocomplete-heatmap
click id=home-destination-autocomplete-heatmap
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
open https://www.airasia.com
click id=home-origin-autocomplete-heatmap
8
click id=home-destination-autocomplete-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
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.
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
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.
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.
open https://www.facebook.com/
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
open https://www.facebook.com/
pause 5000
12
click xpath = //a[@id='pageLoginAnchor']/div
pause 2000
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
open https://www.facebook.com/
13
type xpath = //input[@id = “pass”] password
pause 5000
click id=u_0_3
click linkText=Home
click id=userNavigationLabel
pause 2000
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.
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’:
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:
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.
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:
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
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");
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";
}
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!";
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