You are on page 1of 5

FILLED BY THE STUDENT:

Mehtab Singh Gill


__________________________________________________________________________________

Computer Science Student’s Name

Techniques 5284467
__________________________________________________________________________________

Software Testing Student’s ID Number

2021-09-29
___________________________________________________________________________________

Course: Date (Date (yyyy – mm - dd))

Automated Testing
Tools
420-TZ3-GX

Assignment 1

PROFESSOR: Hansy Ross Salvant


SECTION/COHORT: 19525

EXAM RULES: FILLED BY THE PROFESSOR:


 All students must have an ID to confirm their
identity. Evaluated Competencies:
 No student will be allowed to enter the evaluation
room 20 minutes after the evaluation has started.
1)0177(2,3)
 Students may not leave the evaluation room during 2)
the exam period for any reason. 3)
 Any student who arrives late will not be given any 4)
extra time to complete his or her evaluation. 5)
 Students may be assigned a specific desk/location by
the teacher.
 Students may not bring any food or drink other than Time Allowed: 120 minutes
water into the evaluation room.
 All communication devices including but not limited Materials Allowed: Pen and Pencil only
to cell phones, smart phones, smart watches, iPods,
(Red Pen is forbidden )
pagers and Web-accessible electronic devices must
be turned off and left at a place designated by the
teacher. Failure to do so may lead to the removal of Total Mark: 20 Points
the evaluation.
 Cheating attempts or any assistance offered to Mark Obtained:
others will merit a mark of zero on the evaluation.
This includes but not limited to speaking or looking
around the evaluation room. In this case, the
teacher will seize the evaluation documents and
submit a written report to the Program Coordinator.
Automated Testing Tools
420-TZ3-GX
STUDENT’S NAME:_____________ _____________________________________________________________________________________________________________

public class Banks {

WebDriver objBank;

public void openBrowser() {

System.setProperty("webdriver.chrome.driver", "C:\\Users\\maria\\OneDrive -
matrixcollege.ca\\Course\\Automated-18902\\19511\\chromedriver_win32\\chromedriver.exe");

objBank =new ChromeDriver();

public void openPage() {

objBank.get("http://zero.webappsecurity.com/login.html");

public void test() {

WebElement login = objBank.findElement(By.id("user_login"));

login.click();

login.clear();

login.sendKeys("username");

WebElement pass = objBank.findElement(By.name("user_password"));

pass.clear();

pass.click();

pass.sendKeys("password");

objBank.findElement(By.cssSelector("#login_form > div.form-actions > input")).click();

2|Page
Automated Testing Tools
420-TZ3-GX
STUDENT’S NAME:_____________ _____________________________________________________________________________________________________________

public void testVerification() {

WebElement cash =
objBank.findElement(By.xpath("/html/body/div[1]/div[2]/div/div[2]/div/div/h2[1]"));

if (cash.isDisplayed()) {

System.out.print("Test pass");

public void closeBrowser() {

objBank.close();

public static void main(String[] args) {

// TODO Auto-generated method stub

Banks b = new Banks();

for (int i = 0; i <2; i++) {

b.openBrowser();

b.openPage();

b.test();

b.testVerification();

b.closeBrowser();

3|Page
Automated Testing Tools
420-TZ3-GX
STUDENT’S NAME:_____________ _____________________________________________________________________________________________________________

1.- Explain as much as you can the above code

Above code is all about testing web application of bank. In the code there one class named Banks and all
the different function mentioned in that class.

Our program starts from public static void main and in that there is a object named objBank. And in this
function, they have called several functions.

There are five functions has been created here.

When we call Open browser function then it will open the browser through our installed chrome driver
executable file.

In the second function openPage will open the given page http://zero.webappsecurity.com/login.html.

Third function test will test the whole web page. And test verification will tell us that the test case is
passed or not.

In the last function browser will be closed.

2.- Explain in detail the difference between the test automation and the manual test.

In manual testing, a human performs the tests step by step, without test scripts. In automated testing,
tests are executed automatically via test automation frameworks, along with other tools and software.

The biggest difference between manual and automation testing is who executes the test case. In manual
testing, the human tester does it. In automation testing, the tool does it.

Automation testing is the process in which testers utilize tools and scripts to automate testing efforts.

3.- Explain why and how we can use selenium webdriver in a java project.

Actually, There are several reason to use selenium webdriver. Selenium WebDriver is used to automate
web application testing to verify that it works as expected. It supports many browsers such as Firefox,
Chrome, Opera, Safari, etc. In order to execute your test on Google Chrome browser, you need to
download the chrome driver and set it up in your project.

4|Page
Automated Testing Tools
420-TZ3-GX
STUDENT’S NAME:_____________ _____________________________________________________________________________________________________________

4.- Name the different locator and explain how we can obtain their value.

There is total 7 locator.

By ID - driver.findElement(By.id (<element ID>))

By name - driver.findElement(By.name (<element name>))

By class name - driver.findElement(By.className (<element class>))

By Tag Name - driver.findElement(By.tagName (<htmltagname>))

By link text - driver.findElement(By.linkText (<linktext>))

By xpath - driver.findElement(By.xpath (<xpath>))

By CSS - driver.findElement(By.cssSelector (<css selector>))

5|Page

You might also like