Professional Documents
Culture Documents
Objective :
1|Page
MCA52L Software Quality and Testing
2|Page
MCA52L Software Quality and Testing
3|Page
MCA52L Software Quality and Testing
Introduction:
What is Automation?
- Automation is making a process automatic, eliminating the need for human
intervention.
- Is a self-controlling or self-moving process.
- Automation software offers automation wizard and commands of its own in
addition to providing task recording and re-play capabilities.
- Using these tools we can record the task
- Then if needed use the editor to edit the task, add new commands or using GUI
automation
wizards
Benefits of Automation
Fast: test automation runs faster than human users
Reliable: it performs precisely the same operations at each time elimination
human errors
Repeatable: It performs the same operation with different combination of data
in a less time
Programmable: We can use sophisticated tests that brings out hidden
information
Reusable: We can develop reusable components which can run on different
versions of application under test
Regression testing: easy to conduct regression test
Enabling 24*7 testing: test can be schedule and supports unattended recovery
Robust Verification: Support robust verification mechanism than any other
testing tools
4|Page
MCA52L Software Quality and Testing
The test plan will be maintained in a central repository. This will help to
produce reusable tests cases in future. The information is sharable and
preserved.
Test case: Contains description of test case and test steps.
Test script: Automated test script associated with each test case will be stored in
the quality center repository.
Test sets: This will be a set of selected test cases and associated test scripts. The
tests sets are executed from the quality center onto remote machines. The status
of each execution is stored in the respective test case execution status. The status
can be either pass/fail, it doesn’t maintain the exact details of the execution.
Test logs: The test script execution logs are stored in global repository. It contains
the status of each test case.
Reusable components: The repetitive functions that are invoked in most of the
functions are stored, which reduces the coding redundancies.
Data sheets: contains the test data used for execution. it can be populated by the
database or manually.
Automation Activity:
Record the application GUI
Write Script
Execute script
Review the script
Modify script if any changes.
Execute scripts on at least two machines
Store the script in central repository
Execute the script from central repository
Verify the execution status in central repository
Verify the test logs on common server
Prepare the test reports
5|Page
MCA52L Software Quality and Testing
1. History of Selenium
• In 2004 invented by Jason R. Huggins and team.
• Original name is JavaScript Functional Tester [JSFT]
• Open source browser based integration test framework built originally by
Thought works.
• 100% JavaScript and HTML
• Web testing tool
• That supports testing Web 2.0 applications
• Supports for Cross-Browser Testing(ON Multiple Browsers)
• And multiple Operating Systems
• Cross browser – IE 6/7, Firefox .8+, Opera, Safari 2.0+
2. What is Selenium?
• Acceptance Testing tool for web-apps
• Tests run directly in browser
• Selenium can be deployed on Windows, Linux, and Macintosh.
• Implemented entirely using browser technologies -
1. JavaScript
2. DHTML
3. Frames
3. Selenium Components
– Selenium IDE
– Selenium RC
– Selenium WebDriver
– Selenium Grid
Selenium IDE
✓ Selenium IDE allows you to save tests as HTML, Java, Ruby scripts, or
any other format
6|Page
MCA52L Software Quality and Testing
✓ After Installation a button will appear on the right hand side of the
address bar.
✓ To run the Selenium IDE, simply click the button to the right of the
address bar.
7|Page
MCA52L Software Quality and Testing
Pause/Resume
Navigation Panel Stop:
✓ Run All: Runs the entire test suite when a test suite with multiple test
cases is loaded.
8|Page
MCA52L Software Quality and Testing
✓ Run: Runs the currently selected test. When only a single test is loaded
this button and the Run All button have the same effect.
9|Page
MCA52L Software Quality and Testing
✓ Now perform the operations on the application as you are testing the
application.
✓ Once you are done with the recording click on the stop recording button
and save the test case through the file menu. By default it will be saved as
a Selenese script (.side format)
Command Table
Command : Command column describes name of command.
Target :Target column describes Target element id or name or Xpath
Value :Value column describes Value of an element
✓ Selenium IDE will now automatically wait for you, at every command
✓ Commands which take a locator will wait for the element to appear.
✓ In case that is not enough, the pause command can be used instead.
10 | P a g e
MCA52L Software Quality and Testing
Recording
✓ You will see a context menu showing verify and/or assert commands
Editing
✓ Insert Command
✓ Insert Comment
Select the line to be changed ,edit it using the Command, Target, Value
Click the Run button to run the currently displayed test case.
Click the Run All button to run all the test cases in the currently loaded
test suite.
11 | P a g e
MCA52L Software Quality and Testing
The Pause button can be used to stop the test case while it is running.
The icon of this button then changes to indicate the run is paused.
particular command.
-Select a command, right-click, and from the context menu select Toggle
Breakpoint.
-You can tell the IDE to begin running from a specific command in the
- Select a command, right-click, and from the context menu click Play
from here.
Selenese
Types of Selenese
Actions
Accesors
12 | P a g e
MCA52L Software Quality and Testing
Assertions
• Few commands comes with parameters (They are optional and depends on
the command)
13 | P a g e
MCA52L Software Quality and Testing
• Open
• Click
Performs a click operation, and optionally waits for a new page to load.
• VerifyTitle/assertTitle
• VerifyTextPresent
• VerifyElementPresent
• VerifyText
Verifies expected text and its corresponding HTML tag are present on the
page.
• VerifyTable
Test Scenario
✓ Launch way2sms
✓ Type Phone number
✓ Type Password
✓ Click Login
✓ After Page Load Verify text
✓ logout
14 | P a g e
MCA52L Software Quality and Testing
15 | P a g e
MCA52L Software Quality and Testing
c) Click Search
d) goto Oracle.com.site
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-
downloads-2133151.html
a) Open your Personal Folder and Double Click on Download Enter JDK8
Download
16 | P a g e
MCA52L Software Quality and Testing
g) Go to Properties
i) Environment Variables
OK Cancel
k) Click OK
Paste
c:\programfiels\java\jdk18.0_20\bin;
C:\> D:
D:\> java
D:\> javac
17 | P a g e
MCA52L Software Quality and Testing
c) Click Search.
e) Go to Eclipse.org.site
g) Click Download
r) Switch to Workspace
s) Other
a) Eclipse
b) File
18 | P a g e
MCA52L Software Quality and Testing
c) New
i) Click Finish
j) Project Created
Note:-
2. Properties
3. Java Compiler
1. Libraries
3. Click(Add Library)
5. Click Finish
6. Click Ok
19 | P a g e
MCA52L Software Quality and Testing
b) New
c) Package
e) Click Finish
b) New
c) Class
g) Click Finish
a) Goto Google
c) Go to seleniumhq.org site
f) Extract Download
20 | P a g e
MCA52L Software Quality and Testing
i) Properties
k) Libraries
n) click Ok
21 | P a g e
MCA52L Software Quality and Testing
package home;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
System.setProperty("webdriver.chrome.driver","D://SoftwareTesting//
chromedriver.exe");
WebDriver driver=new ChromeDriver();
//To navigate to URL
driver.get("http://www.way2sms.com/");
Thread.sleep(5000);
driver.findElement(By.id("mobileNo")).sendKeys("9700339582");
Thread.sleep(5000);
driver.findElement(By.name("password")).sendKeys("hanuman");
Thread.sleep(5000);
driver.findElement(By.xpath("//b[@id='mainErr']/following::*[5
]")).click();
Thread.sleep(5000);
//Verification Point
String o="http://www.way2sms.com/send-sms";
String z=driver.getCurrentUrl();
if(z.equals(o))
{
System.out.println("Login Sucessful_Test Passed");
}
else
{
System.out.println("Login UnSucessful_TestFailed");
}
//Close Site
driver.close();
}}
22 | P a g e
MCA52L Software Quality and Testing
Output:-
23 | P a g e
MCA52L Software Quality and Testing
package home;
import java.io.File;
import java.io.IOException;
import jxl.CellView;
import jxl.Workbook;
import jxl.WorkbookSettings;
import jxl.format.UnderlineStyle;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
public class Student_excel_write {
24 | P a g e
MCA52L Software Quality and Testing
25 | P a g e
MCA52L Software Quality and Testing
Label label;
label = new Label(column, row, s, timesBoldUnderline);
sheet.addCell(label);
}
private void addNumber(WritableSheet sheet, int column, int row,
Integer integer) throws WriteException,
RowsExceededException{
Number number;
number = new Number(column, row, integer, times);
sheet.addCell(number);
}
private void addLabel(WritableSheet sheet, int column, int row,
String s)
throws WriteException, RowsExceededException {
Label label;
label = new Label(column, row, s, times);
sheet.addCell(label);
}
public static void main(String[] args) throws WriteException,
IOException {
Student_excel_write test = new Student_excel_write();
test.setOutputFile("D://SoftwareTesting//src//Firstpackage//Student.xls");
test.write();
26 | P a g e
MCA52L Software Quality and Testing
Output:-
27 | P a g e
MCA52L Software Quality and Testing
package home;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
28 | P a g e
MCA52L Software Quality and Testing
Output:-
29 | P a g e
MCA52L Software Quality and Testing
Lab Program 10: Write and test a program to get the number of items in a
list or a combo box
package home;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
System.setProperty("webdriver.chrome.driver","D://SoftwareTesting//chromedr
iver.exe");
WebDriver driver=new ChromeDriver();
//To navigate to URL
driver.get("http://newtours.demoaut.com/");
Thread.sleep(5000);
//Syntax:
//objectName.Method(StaticClass.Locator("value")).OperationMethod();
//Click on Register Link
driver.findElement(By.linkText("REGISTER")).click();
Thread.sleep(5000);
//Pass text into Textbox for FirstName
driver.findElement(By.name("firstName")).sendKeys("Aarav");
Thread.sleep(5000);
driver.findElement(By.name("lastName")).sendKeys("Prof");
Thread.sleep(5000);
driver.findElement(By.name("phone")).sendKeys("9703336699");
Thread.sleep(5000);
30 | P a g e
MCA52L Software Quality and Testing
driver.findElement(By.id("userName")).sendKeys("abcd@gmail.com");
Thread.sleep(5000);
driver.findElement(By.name("address1")).sendKeys("chennai fasf");
Thread.sleep(5000);
driver.findElement(By.name("address2")).sendKeys("chennai hjgfhdfhfdg
fasf");
Thread.sleep(5000);
driver.findElement(By.name("city")).sendKeys("chennai");
Thread.sleep(5000);
driver.findElement(By.name("state")).sendKeys("TN");
Thread.sleep(5000);
driver.findElement(By.name("postalCode")).sendKeys("5000221");
Thread.sleep(5000);
//Get all the option from dropdown list and assign into List
List<WebElement> listOptionDropdown = s.getOptions();
// Count the item dropdown list and assign into integer variable
int dropdownCount = listOptionDropdown.size();
//selectByIndex();
//selectByVisibleText("INDIA");
s.selectByVisibleText("INDIA");
Thread.sleep(5000);
driver.findElement(By.id("email")).sendKeys("abcd@gmail.com");
Thread.sleep(5000);
31 | P a g e
MCA52L Software Quality and Testing
driver.findElement(By.name("password")).sendKeys("Madhvaraj");
Thread.sleep(5000);
driver.findElement(By.name("confirmPassword")).sendKeys("Madhvaraj
");
Thread.sleep(5000);
//Image Button
driver.findElement(By.name("register")).click();
Thread.sleep(5000);
//close browser
driver.close();
}
Output:-
Starting ChromeDriver 2.40.565498
(ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 32545
Only local connections are allowed.
Sep 21, 2018 10:42:15 PM org.openqa.selenium.remote.ProtocolHandshake
createSession
INFO: Detected dialect: OSS
Total Number of item count in dropdown list = 264
32 | P a g e
MCA52L Software Quality and Testing
Lab Program 11: Write a test program to automate a webpage using JXL.
package firstPackage;
import java.io.File;
import java.io.IOException;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
//Open Excel File for Read and Write ,which we placed in same
package only
File f=new
File("E:\\AutomationProject\\src\\firstPackage\\TestData_Way2sms.xls");
33 | P a g e
MCA52L Software Quality and Testing
Workbook readwb=Workbook.getWorkbook(f);
WritableWorkbook
wwb=Workbook.createWorkbook(f,readwb);
WritableSheet wsh=wwb.getSheet(0);
for(int i=1;i<numberofr;i++)
String x=readsht.getCell(0,i).getContents();
String y=readsht.getCell(1,i).getContents();
System.setProperty("webdriver.chrome.driver","E://Madhwaraj//chromed
river.exe");
driver.get("http://www.way2sms.com/");
Thread.sleep(5000);
driver.findElement(By.id("mobileNo")).sendKeys(x);
Thread.sleep(5000);
driver.findElement(By.name("password")).sendKeys(y);
Thread.sleep(5000);
driver.findElement(By.xpath("//b[@id='mainErr']/following::*[5]")).click();
Thread.sleep(5000);
34 | P a g e
MCA52L Software Quality and Testing
//Verification Point
String o="http://www.way2sms.com/send-sms";
String z=driver.getCurrentUrl();
if(z.equals(o))
wsh.addCell(l);
else
System.out.println("Login UnSucessful_TestFailed");
wsh.addCell(l);
//Close Site
driver.close();
wwb.close();
readwb.close();
}
}
35 | P a g e
MCA52L Software Quality and Testing
Output:-
36 | P a g e
MCA52L Software Quality and Testing
37 | P a g e