Test Automation Using Selenium - Report
Test Automation Using Selenium - Report
ABSTRACT
INTRODUCTION
There are high chances that the final code has errors of functionality and design. For
the identification of the issues before the occurrence in the critical environment, it is a
prerequisite to performing the testing of software.
Testing is a vast landscape that consists of several categories like black-box testing,
white box testing, system testing, system integration testing, performance testing, and
load testing. Some of these testing categories perform better with Automation, while
others get desirable results with Manual Testing. Automation testing has been a
buzzword in the world of testing. It has helped companies take new features to market
faster while ensuring a bug-free user experience. It has improved the productivity of
developers and QA testers, while ensuring a massive increase in test coverage, to keep
up with the proliferation of different devices, browsers, and operating systems.
However, manual testing has retained its own special place. We understand software
life cycle, various test types, bug life cycle and test automation using selenium in
following sections.
Process:
First of all business analyst will take an appointment from the customer,
collect the template from the company and meet the customer on appointed
date, gather the requirements with the support of that template and comes back
to the company with the requirement document.
The engagement manager go through the requirements, if he find any extra
requirements then he will deal with excess cost of the project.
If at all he finds any confused requirements, then he will ask the concern team
to build a prototype, demonstrate that prototype to the customer, gather’s the
2. ANALYSIS PHASE:
Tasks:
Feasibility study
Tentative planning
Technology selection and Environment confirmation
Requirement analysis
Process:
b. Tentative planning: In this section resource planning and time planning will be
temporarily done. c. Technology selection & Environment confirmation: The list of
all technologies required for accomplishing the project successfully will be analyzed,
the environment suitable for that project will be selected and mentioned here in this
section.
d. Requirement analysis: The list of all the requirements that are required by the
company to accomplish this project successfully will be analyzed and listed out
clearly in this section.
3. DESIGN PHASE:
Tasks:
Roles:
Process:
The chief architect will divide the whole project in to modules by drawing some
diagrams using unified modeling language (UML).
The Team lead will divide the modules into sub modules by drawing some
diagrams using the same UML.
In this phase they will also design GUI part of the application, as well as
PSEUDO CODE also developed
Tasks:
Process: The developers will develop the actual source code by following the coding
standards and also with the support of Technical Design Document
Tasks: Testing
Process:
The Testing department will receive the requirement document and the test
engineers will start understanding the requirements.
While understanding the requirements, if they get any doubts they will list out all
the doubts in Requirement clarification Note and sent it to the author of the
requirement document and wait for the clarification.
Once the clarification is given and after understanding all the requirements clearly
they will take the test case template and write the Test cases.
Once the first build is released they will execute the test cases.
If at all any defects are found they will list out all the defects in the defects profile
and send it to the development department and will wait for the next build.
PRAKASAM ENGINEERING COLLEGE Page 4
Once the next build is released they will re execute the required test cases.
If at all any more defects are found they will update the defect profile. Send it to
development department and will wait for the next build.
This Process continuous till the product is defect free
Delivery:
Process: The Deployment engineers will go to the customers place, install the
application in to the customers environment and handover the original software to the
client.
Proof: The final official agreement made between the customer and company is proof
document for Delivery.
Maintenance: Once the application is delivered. The customer will start using it,
while using if at all they face any problems then that particular problem will be
created as tasks. Based on the tasks corresponding roles will be appointed. They will
define the process and solves the problem .This process is known as Normal
Maintenance. But some customers may request for continuous Maintenance, in that
case a team of members will be continuously working in the client site in order to take
care of their Software.
Software Testing is Important because if there are any bugs or errors in the
software, it can be identified early and can be solved before delivery of the software
product. Properly tested software product ensures reliability, security and high
performance which further results in time saving, cost effectiveness and customer
satisfaction. Below are the types of software testing,
4. SYSTEM LEVEL TESTING: In this level the Black Box test engineers will
conduct so many types of testing like load testing, performance testing, stress testing,
compatibility testing, system integration testing etc. These type of Testings are also
conducted:
These type of Testings are also conducted:
1. Usability Testing
2. Functionality Testing
3. Performance Testing
4. Security Testing
Testing: Testing is a process in which defects are identified, isolated, subjected for
rectification and ensure that the product is defect free, in order to produce the quality
product and hence the customer satisfaction. (or) Verification & Validation of
software is called Testing.
2. Test Development
THE GUIDE LINES TO BE FOLLOWED BY A TEST ENGINEER, SOON AFTER
THE USE CASE DOCUMENT IS RECEIVED:
1. Identify the module to which the use case belongs to.
A: Security module.
2. Identify the functionality of the use case with the request of total functionality. A:
Authentication.
3. Identify the actors involved in the use case. E.g.: Normal user/Admin user.
4. Identify the inputs required for testing. E.g.: Valid and invalid user names and
passwords.
4. Result Analysis: In this phase the test engineer will compare the actual value with
the expected value. If both are matching, then he will decide the result as PASS
otherwise FAIL. Note: If at all the Test case is not executed in any reason, then the
test engineer will specify BLOCKED in the result column.
Ex: If application has 5 pages, in each page a next button will be available, when we
click on next button, we will enter into next page, if next page button of 4th page is
not working, we can’t enter into 5th page and all the test cases related to that 5th page
can’t test. The result to all that test cases will be BLOCKED.
AUTOMATION TESTING
Automation Testing is a software testing technique that performs using special
automated testing software tools to execute a test case suite. On the contrary, Manual
Testing is performed by a human sitting in front of a computer carefully executing the
test steps.
Following steps are followed in an Automation Process
1) Test Tool Selection
2) Define scope of Automation
3) Planning, Design and Development
4) Test Execution
5) Maintenance
Manual vs Automation
INTRODUCTION TO SELENIUM
Selenium is a free (open-source) automated testing framework used to validate web
applications across different browsers and platforms.
You can use multiple programming languages like Java, C#, Python, etc to create
Selenium Test Scripts. Testing done using the Selenium testing tool is usually referred
to as Selenium Testing.
Selenium Software is not just a single tool but a suite of software, each piece catering
to different Selenium QA testing needs of an organization. Here is the list of tools
Selenium Integrated Development Environment (IDE)
Selenium Remote Control (RC)
WebDriver
Selenium Grid
WebDriver:
The WebDriver proves to be better than Selenium IDE and Selenium RC in many
aspects. It implements a more modern and stable approach in automating the
browser’s actions. WebDriver, unlike Selenium RC, does not rely on JavaScript for
Selenium Automation Testing. It controls the browser by directly communicating
with it.
The supported languages are the same as those in Selenium RC.
Java
C#
PHP
Selenium Architecture
get() : This command opens a new browser instance and navigates to the URL
getTitle() : This command retrieves the title of the webpage on which the user
is currently working.
getCurrentUrl():This command retrieves the URL of the webpage that the user
is presently viewing.
Quit(): End all open browser Instances, whereas the Close() method closes
current browser instance
to(): This method is used to load a new web page in the existing browser
window.
PRAKASAM ENGINEERING COLLEGE Page 15
navigate() : This method opens a new browser window with a new web page.
It accepts a String parameter as well as a void return type.
element.clear():if the element is a text entry, its value will get cleared,
and nothing is passed as a parameter to this procedure.
4. Action Commands
The Actions class has a number of methods that return an action object, unless
otherwise stated. In general, the methods of the actions class can be classified into two
groups:
click() :The method is used to perform a click operation at the current mouse
position. This approach has no idea what it's clicking on or where it's clicking.
It only makes a single click on the current place. It does not take any
parameters and returns a self-reference.
keyDown(): To test the action of pressing and holding a key, use this
approach. The keys that can be used are Shift, Ctrl and Alt. It takes one of
three input parameters: Keys.SHIFT, Keys.CONTROL, or
Keys.ALT. Selenium will throw an error as IllegalArgumentException if the
passed key isn't one of those.
keyUp() : This method is used to release a key that was pressed previously
with the keyDown() method, meaning it's just opposite to keyDown. If you try
to use this method on an unpressed key, it will result in undefined behaviour.
sendKeys(CharSequence): This method is used to enter alphanumeric and
special character keys into WebElements like textareas and textboxes. The
preceding method differs from WebElement's sendKeys(CharSequence)
method. if the provided keys are null it will through
IllegalArgumentException
package com.sel.practice;
import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.firefox.FirefoxDriver;
//comment the above line and uncomment below line to use Chrome
import org.openqa.selenium.chrome.ChromeDriver;
public class SampleTest {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","C:\\Users\\bujji\\OneDrive\\D
ocuments\\chromedriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "http://demo.guru99.com/test/newtours/";
String expectedTitle = "Welcome: Mercury Tours";
String actualTitle = "";
// launch Fire fox and direct it to the Base URL
driver.get(baseUrl);
// get the actual value of the title
actualTitle = driver.getTitle();
if (actualTitle.contentEquals(expectedTitle)){
System.out.println("Test Passed!");
driver.findElement(By.name("passwd")).sendKeys("abcdefghlkjl");
}
}
package com.sel.practice;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.*;
public class SampleTest3 {
public static void main(String[] args) throws InterruptedException {
Thread.sleep(5000);
//Radio Button1 is de-selected and Radio Button2 is selected
radio2.click();
System.out.println("Radio Button Option 2 Selected");
// Selecting CheckBox
WebElement option1 = driver.findElement(By.id("vfb-6-0"));
} else {
System.out.println("Checkbox is Toggled Off");
}
PRAKASAM ENGINEERING COLLEGE Page 20
driver.close();
}
}
packagecom.sel.practice;
importorg.openqa.selenium.By;
importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.chrome.ChromeDriver;
publicclassElementLocators {
publicstaticvoidmain(String[] args) {
String baseUrl = "http://demo.guru99.com/test/link.html";
System.setProperty("webdriver.chrome.driver","C:\\Users\\bujji\\OneDrive\\D
ocuments\\chromedriver\\chromedriver.exe");
WebDriver driver = newChromeDriver();
driver.get(baseUrl);
driver.findElement(By.linkText("click here")).click();
System.out.println("title of page is: " + driver.getTitle());
driver.quit();
}
}
AlertBoxes:
packagecom.sel.practice;
importorg.openqa.selenium.By;
importorg.openqa.selenium.WebDriver;
importorg.openqa.selenium.chrome.ChromeDriver;
importorg.openqa.selenium.NoAlertPresentException;
importorg.openqa.selenium.Alert;
publicclassAlertBox {
publicstaticvoidmain(String[] args)
throwsNoAlertPresentException,InterruptedException {
System.setProperty("webdriver.chrome.driver","C:\\Users\\bujji\\OneDrive\\D
ocuments\\chromedriver\\chromedriver.exe");
WebDriver driver = newChromeDriver();
// Alert Message handling
driver.get("http://demo.guru99.com/test/delete_customer.php");
driver.findElement(By.name("cusid")).sendKeys("53920");
driver.findElement(By.name("submit")).submit();
// Switching to Alert
Alert alert = driver.switchTo().alert();
// Capturing alert message.
String alertMessage= driver.switchTo().alert().getText();
// Displaying alert message
System.out.println(alertMessage);
PRAKASAM ENGINEERING COLLEGE Page 21
Thread.sleep(5000);
// Accepting alert
alert.accept();
}
}
File Upload:
packagecom.sel.practice;
importorg.openqa.selenium.*;
importorg.openqa.selenium.chrome.ChromeDriver;
importorg.openqa.selenium.firefox.FirefoxDriver;
publicclassFileUpload {
publicstaticvoidmain(String[] args) throwsInterruptedException {
System.setProperty("webdriver.chrome.driver","C:\\Users\\bujji\\OneDrive\\D
ocuments\\chromedriver\\chromedriver.exe");
String baseUrl = "http://demo.guru99.com/test/upload/";
// WebDriver driver = new FirefoxDriver();
WebDriver driver = newChromeDriver();
driver.get(baseUrl);
WebElementuploadElement = driver.findElement(By.id("uploadfile_0"));
Thread.sleep(5000);
// enter the file path onto the file-selection input field
uploadElement.sendKeys("C:\\newhtml.html");
Selenium is the most effective test automation tool for qa due to its wide range of
features such as open source, supports many languages, integrates easily with many
platforms, has cross browser support and is best suited to test web applications.
Hence, businesses need to prefer selenium tool as a promising test automation tool for
web applications testing. Automated selenium testing services by a next-gen testing
services provider can be leveraged to achieve faster time to market, quicker ROI and
get flawless applications. We have learned the most intriguing features of selenium
and ability to test applications across various web browsers.