Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Test Automation

No description
by

Adrian Benko

on 28 April 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Test Automation

Test Automation in SELENIUM
Test automation for web applications
"
using a software tool to run repeatable tests against the application to be tested
"

Selenium is possibly
the most widely used
open source solution
Test automation supports
• Frequent regression testing
• Rapid feedback to developers
• Support for Agile
• Disciplined documentation of test cases
• Customized defect reporting
• Finding defects missed by manual testing
To Automate or NOT to automate?
if the application’s
user interface will change considerably
in the near future, then any automation might need to be rewritten anyway
sometimes there simply is
not enough time
to build test automation. For the short term, manual testing may be more effective
Selenium
- Selenium is a JavaScript based framework
- is
set
of different software tools
Selenium IDE
Selenium Server (Grid)
Selenium Client Drivers (WebDriver)
Selenium IDE
Selenium Grid
It allows the WebDriver to easily
run large test suites:
in
parallel

on
multiple machines
in multiple environments
you can run
multiple instances
of WebDriver on various operating systems and browser configurations
WebDriver
is the solution for tests that need a little
more than just simple browser actions
and a linear execution
with WebDriver can be added
programming logic
to tests
The automation tool could be implemented for post release validation with continuous integration tools like
Jenkins
WebDriver provides an
API and library
for each of its supported languages
Supported Programming
Languages
Supported OS
Supported Browsers
Roy Osherove: The Art of Unit Testing

if (time.maintaining_existing_automated_test > time.creating_new_test){
Project.fail();
}
One of the reason: “
poor element locator managemen
t”
Element Locator Management
Wait!
Take a screenshot
Execute tests overnight and check saved images the next day for bugs/issues/failures
When bilingual application is tested, screenshots can help with the linguistically review.
Cookies
Customized Profile
Change User Agent
Set preferred language

Set trusted sites

Enable Firefox extensions
Features
Adrián Benkó
Sr. Software Test Automation Engineer

Methodology
• Centralize your locator definition!
• Advantage: There is
only ONE place

where you have to update locator’s
definition when the UI changes.

package com.epam.training.dictionary;
public class Dic {

public static String
DROPDOWN_URL
= "http://www.asp.net/DropDown.aspx";
public static String
ICE_CREAM_FLAVOR

= "ctl00_SampleContent_TextLabel";
Location
Technique
driver.findElement:
By.id
By.linkText
By.cssSelector
By.xpath
Implicit
Explicit
to delay your test's execution until the content is loaded
is code you define to wait for a certain condition to occur before proceeding further in the code
~Thread.sleep()
• tells WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available

• Is set for the life of the WebDriver object instance
// wait till the auto-complete part is visible
ExpectedCondition<Boolean> e = new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
d.findElement(By.xpath(Dic.FirstItemInAutocompleteList));
return Boolean.valueOf(true);
}
};
WebDriverWait w = new WebDriverWait(driver, 15);
w.until(e);
Set <Cookie>
cookies
= driver.manage().getCookies();
for (Cookie
cookie
:
cookies
) {
System.out.println("PATH " +
cookie
.getPath()
+ "; NAME: " +
cookie
.getName()
+ "; VALUE: " +
cookie
.getValue()
+ "; EXPIRY: " +
cookie
.getExpiry());
}
driver.manage().
getCookieNamed
("cookieName");

Assert
.assertEquals(
cookie
.getName(), “Price");

Assert
.assertEquals(
cookie
.getValue(), “1.200 GBP");
driver.manage().
deleteAllCookies
();


/**** O P E N EPAM.COM ****/
driver.
get
("
http://www.epam.com/
");

// Verify window title
Assert.
assertTrue
(driver.
getTitle
().contains("
EPAM Systems
"), "
FAIL: Title is NOT 'EPAM Systems
'");
System.out.println("
PASS: title is 'EPAM Systems
'");

// Check if the 'Careers' link is displayed
WebElement careersLink = driver.
findElement
(
By.xpath
("
//div[@id='topnav']//a[contains(text(), 'Careers')]
"));

Assert.
assertTrue
(careersLink.
isDisplayed
(), "
'Careers' link was NOT found in the header section
.");
System.out.println("
PASS: 'Careers' link was foun
d");

/***** C A R E E R S P A G E *****/
careersLink.
click
();
// Navigate to 'Careers' page

// Check if the 'Careers' page is displayed
Assert.assertTrue(driver.
getTitle
().contains("
Careers
"), "
FAIL: 'Careers' is not displayed
");

// Get counties from the left section
List<WebElement> counties = driver.
findElements(By.cssSelector
(
"
.aside-navigation.parbase.section>ul>li>a
"));

boolean isFound = false;
for (WebElement webElement : counties) {
if (webElement.
getText
().contains("
Hungary
")) isFound = true;
System.out.print(webElement.getText() + " ");
}
Assert.assertTrue(isFound, "
'Hungary' was NOT found in the list
");
driver.
findElement(By.linkText
("
Hungary
")).click();

/**** O P E N P O S I T I O N S I N H U N G A R Y *****/
Assert.assertTrue(driver.
getTitle
().contains("
Hungary
"), "
FAIL: 'Hungary' page is not displayed
");

// set Group filter to Software Engineering
driver.
findElement(By.xpath
("/
/div[@class='jo-filter']//span[@class='jo-dd-arrows']
")).click();
WebElement groupFilters = driver.
findElement(By.xpath
("
//div[@class='jo-sections-dropdown']/div
"));
Assert.assertTrue(groupFilters.
isDisplayed
(), “
FAIL: Group Filters
");

// get all group filters
List<WebElement> listGroupFilters =
groupFilters.
findElements(By.xpath
("//div[@class='jo-sections-dropdown']/div/ul/li"));

for (WebElement webElement : listGroupFilters) {
System.out.print(webElement.
getText
() + " ");
if (webElement.
getText
().contains("
Software Engineering
"))
webElement.
click
();
}

// check if the 'Apply' button is available
WebElement btnApply = groupFilters.
findElement(By.linkText
("
Apply
"));
Assert.assertTrue(btnApply.
isDisplayed
(), "'
Apply' button is NOT displayed
");
btnApply.
click
();

// 'Consulting and Business Analysis' section is not displayed anymore
Assert.assertFalse(driver.
findElement( By.xpath
("
//*[@id='jo- start']//h3[contains(text(),'Consulting and Business Analysis')]
")).
isDisplayed
(),
"'
Consulting and Business Analysis' IS displayed
.");

// Type in 'Test' to search field
WebElement jobSearch = driver.
findElement(By.xpath
( "
//form[@class='jo-search']//input[@type='text']
"));
Assert.assertTrue(jobSearch.
isDisplayed
(), "
Input field is NOT displayed!
");
jobSearch.
clear
();
jobSearch.
sendKeys
("
Test
");
WebElement searchIcon = jobSearch.
findElement(By.xpath
(
"
//input[@type='button' and @class='jo-search-button']
"));
Assert.assertTrue(searchIcon.
isDisplayed
(), "'
Search icon' is NOT displayed
");
searchIcon.
click
();

WebElement expandedPosition = driver.
findElement(By.xpath
(
"
//div[@class='jo-sections']//li[@class='jo-position expanded']
"));

if ( expandedPosition.
isDisplayed
() && (expandedPosition.findElement(By
.xpath("
//h4[@class='jo-title ']
"))
Assert.assertTrue(expandedPosition.
findElement(By.xpath
("
//h4[@class='jo-title']
")).
getText
().contains("
Test
"),
"
There are no opened Tester positions
");

Useful links
31 Days of Testing—Day 11: Maintainable Functional Automation
(http://frazzleddad.blogspot.com/2011/12/31-days-of-testingday-11-maintainable.html)
31 Days of Testing—Day 13: Functional Test 201 (Common Problems)
(http://frazzleddad.blogspot.com/2011/12/31-days-of-testingday-13-functional.html)
WebDriver: Advanced Usage
(http://seleniumhq.org/docs/04_webdriver_advanced.html)
Selenium WebDriver - Wait for an element to load
(http://deanhume.com/Home/BlogPost/selenium-webdriver---wait-for-an-element-to-load/64)
Selenium Wiki
(http://www.seleniumwiki.com/)
Exploiting current and exploring new
(http://rostislav-matl.blogspot.com/)
Tips and Tricks for using WebDriver
(http://code.google.com/p/selenium/wiki/TipsAndTricks)
Selenium Advanced User Interactions – The Automated Tester
(http://www.theautomatedtester.co.uk/blog/2011/selenium-advanced-user-interactions.html)

It operates as a
Firefox add-on

provides an easy-to-use interface for
developing and running
individual test cases or entire test suites
Selenium IDE
records
your browser activity in various selenium dialects.

Create
Delete
Print out the value
Disable confirmation dialog
for http://user:password@site
Full transcript