secret ingredient for automation success · 3. agenda. 01 introduction. 02 test automation. 03...
TRANSCRIPT
Secret Ingredient for Automation Success –Page Object Model (POM)
#TestExpo
Matthew Manickakumar
About me
Senior Automation Test Engineer.
Over 13 years of working experience in Test automation.
Extremely passionate about Test Automation and technical troubleshooting.
Worked with many tools Test Automation tools eg: Winrunner, QTP, UFT, Rational Robot, RFT, Selenium, Testcomplete, Xamarin UI, Appium etc.
Certified by HP, IBM, ISTQB, TMap.
01 Secret Ingredient for Automation Success – Page Object Model (POM)
3© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
Agenda
01 Introduction02 Test Automation03 Tools & Frameworks04 Challenges from QualityReport05 Scope06 Working mechanism
07 What is Page Object08 Pattern 01 – Case Study09 Pattern 02 – Case Study10 Exercise11 Pattern 03 – Case Study12 Tips
Questions
TODO
4© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
01 Introduction
5© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
02 What is Test Automation?5
It’s a process to increase your test productivity using a robotic companion.
P.S :Behind every successful test automation there is great tester!
6© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
Where does firms want test automation to be implemented ?
6
Regression Testing
User Acceptance / Pre production Test
Integration Testing
Smartphone
Surface Technology
Web services
Cloud
Cross Browsers
E2E Business Flows
IoT
Apps
RealTime Operating System
Smart Watch
Smart SpeakersSmart Home Appliance
DevOps
7© Capgemini 2019. All rights reserved |Presentation Title | Author | Date7
03 Test and Automation Tools
LeanFT
8© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
29 May 20198
GUI Rich front end
9© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
Test Data
Test Scripts
Reusable Functions
BehaviorDriven
Behavior
Evolution of Test Automation framework
Record & Play
Stand Alone Test Script
Modular
Reusable Functions
Data Driven
Reusable Functions
Test Scripts
Test Data
Test Script
KeywordDriven
Reusable Functions
Test Scripts
Test Data
Keywords
BusinessDriven
Reusable Functions
Test Scripts
Test Data
Keywords
Business Flow
Generations
Feat
ures
10© Capgemini 2019. All rights reserved |Presentation Title | Author | Date 10Copyright © Capgemini, Sogeti and Micro Focus 2018. All Rights Reserved.
04 Quality@Speed is a core challenge for application development
Lack of end to end automation from build to deployment
Too slow testing process
Lack of proper skills for QA & Testing
55%
43%
42%
Top 3 bottlenecks in AD Top 3 challenges with testing digital solutions
11© Capgemini 2019. All rights reserved |Presentation Title | Author | Date 11Copyright © Capgemini, Sogeti and Micro Focus 2018. All Rights Reserved.
Test Automation levels are too low to speed up
Levels of test automation Test automation challenges
12© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
29 May 201912
Published on : 28-06-1999
13© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
05 Scope for Discussion
Non-GUI Test
Web /Browser
Mobile Native
Hybrid
ios
Android
IEEdge Firefox
Chrome Edge
Windows Linux
REST Database Messaging Queues
Mac
Automation Tool
PlayStation Xboxe-sports
GUI Test
14© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
06 Working Mechanism
15© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
06 Working Mechanism
16© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
06 Working Mechanism
17© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
06 Working Mechanism
18© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
06 Working Mechanism
Object Identifier
• ID• Name• Class Name• Tag Name• Link Text• Partial Link Text• XPATH• CSS properties
document. getElementById(‘login’)
document. getElementByName(‘login’)
document. getElementByClassName(‘login’)
document. getElementByTagName(‘login’)
19© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
06 Working Mechanism
Automation ToolTest Script Application Under Test
ObjectIdentifier JQuery
objObject Validation
driver.findElement(By.name("uid")) document.getElementById(‘login’)
Obj.getText()
20© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
Automation ToolTest Script Application Under Test
ObjectIdentifier JQuery
objObject Validation
driver.findElement(By.name("uid")) document.getElementById(‘login’)
Obj.getText()
06 Working Mechanism
21© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
Automation ToolTest Script Application Under Test
ObjectIdentifier JQuery
objObject Validation
driver.findElement(By.name("uid")) document.getElementById(‘login’)
Obj.getText()
Automation ToolTest Script Application Under Test
ObjectIdentifier.action() Jquery.action()
*action = click (), select(), set()... etc
06 Working Mechanism
22© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
Automation ToolTest Script Application Under Test
Script
Data
Library
Page Object
06 Working Mechanism
23© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
Page Object
24© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
07 Page Objects
What is page objects pattern
The goal behind page objects is to abstract any page information away from the actual tests
A page object is an object-oriented class that serves as an interface to a page in the application under test
25© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
07 Page Object Patterns
Why is it significant
Learning a pattern up front can prevent you from making a design mistake, but as in most situations, making a mistake is your very best opportunity to learn
Page Object simply models objects within the test code. This reduces the amount of duplicated code and means that if the UI changes, the fix need only be applied in one place
26© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
08 Page Object Patterns
Case :
1. FrontEnd : Basic Html5
2. Environments: Web browser – Chrome
3. Complexity of application under test : Simple
Requirement :
Pilot task ( testing the water)
Team : Beginner to test automation
Pattern 1
27© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
08 Page Object Patterns
Naivepublic class NoPOM{
Webdriver driver;
@BeforeTestpublic void before(){driver = new FirefoxDriver();driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);}
@Testpublic void test_Home(){driver.get("http://demo.login.com");driver.findElement(By.name("uid")).sendkeys("demo");driver.findElement(By.name("password")).sendkeys("*****");driver.findElement(By.name("bLogin")).click();String HjemHeader = driver
.findElement(By.Xpath("//table//tr[@id='heading']"))
.getText();asserthat(HjemHeader,"hjem");}
}
28© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
08 Page Object Patterns
Pattern 1
Test Data
Test Script
Test Conditions
Library
Test object
assertions
29© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
08 Page Object Patterns
Pros & Cons
• Easy to build• Quick turn around• Requires limited knowledge
• Less reusablity• Duplication of code• Maintance effort is directly propotional to
the design effort
30© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
09 Page Object Patterns
Case :
1. FrontEnd : Html5
2. Database : max 50GB (production)
3. Environments: Web browsers (Chrome / Firefox / Edge)
4. Complexity of application under test : Small business
Requirement :
Over 25-40% of test being automated
Team : Advance test automation users
Pattern 2
31© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
09 Page Object Patterns
Pattern 2 – Level 1<hjem.html>
<Søg.html>
<SignUp.html>
hjem.class
Sog.class
SignUp.class
Test Script
• Object identifier• methods
driver.findElement(By.name("uid")).sendkeys("demo");
32© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
09 Page Object Patterns
Pattern 2 – Level 2
<hjem.html>
<Søg.html>
<SignUp.html>
hjem.class
Sog.class
SignUp.class
Test Script
PageBase.class
header
footer
home
header
footer
search
menu
header
footer
menu
signUp
header footermenu
Test Base
33© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
09 Page Object Patterns
Pattern 2
public class TestBase {protected static WebDriver driver;
@BeforeClasspublic static void setUp(){
driver = new FirefoxDriver();driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@Afterpublic void cleanUp(){
driver.manage().deleteAllCookies();}
@AfterClasspublic static void tearDown(){
driver.close();}
}
hjem.class
Sog.class
SignUp.class
Test Script
Test Base
34© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
09 Page Object Patterns
Pattern 2
public class SignUpPage extends PageBase {
@FindBy(id="firstname")private WebElement firstName;
@FindBy(name="lastname")private WebElement lastName;
@FindBy(xpath=”//input[@name='address']")private WebElement address;
@FindBy(id="zipcode")private WebElement zipCode;
@FindBy(id="signup")private WebElement submitButton;
public SignUpPage (WebDriver driver) {super(driver,”Signup”);
}
public void enterName(String firstName, String lastName){
this.firstName.clear();this.firstName.sendKeys(firstName);
this.lastName.clear();this.lastName.sendKeys(lastName);
}
public void enterAddress(String address, String zipCode){
this.address.clear();this.address.sendKeys(address);
this.zipCode.clear();this.zipCode.sendKeys(zipCode);
}
public HjemPage submit(){submitButton.click();return new HjemPage(driver);
}}
hjem.class
Sog.class
SignUp.class
Test Script
Test Base
• Object identifier• methods
35© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
PageBase
public class PageBase {protected WebDriver driver;protected String pageName;
public PageBase(WebDriver driver, string page){this.driver = driver;this.pageName = page;
}
public static Header header(){ return new Header(driver);
}public static Footer footer(){
return new Footer(driver);}
public static Menu menu(){return new Menu(driver);
}public static boolean isInitialized(){
return (pageName.contains(header.name))? true:false;}
}
hjem.class
Sog.class
SignUp.class
Test Script
PageBase.class
header footermenu
Test Base
36© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
09 Page Object Patterns
Pattern 2
hjem.class
Sog.class
SignUp.class
Test Script
PageBase.class
header footermenu
Test Base
37© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
09 Page Object Patterns
Pattern 2
public class SignUpFormTest extends TestBase {
@Testpublic void signUp(){
driver.get("http://www.123.html");
SignUpPage signUpPage = new SignUpPage(driver);assertTrue(signUpPage.isInitialized());
signUpPage.firstName.set(”frank”); signUpPage.lastName.set(”Jackson");signUpPage.enterAddress("123 Street", "12345");
HjemPage hjemPage = signUpPage.submit();assertTrue(hjemPage.isInitialized());
assertEquals("Thank you", hjemPage.confirmationHeader());}
}
Transition step
Page Object
TestBase
38© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
09 Page Object Patterns
Pros & Cons
• Increased reusablity• Maintainable• structured development cycle
• Planning required• Senior mentorship required during test
design• Support to custom technology is not out
of box
39© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
10 Exercise
Situation 1
Label change from ‘Kategori’ to ‘Type’Id property of this object will change from ‘kategoryselect’ to ‘typeselect’
40© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
10 Exercise
Situation 2
New feature included :1. When focus is brought to [Menu], ribbon opens and object are displayed.2. New section ‘Om BilBasen’ included.3. Menu is visible across all pages.
41© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
10 Exercise
Situation 3
New feature included :1. Old dropdown replaced with new
custom object ‘maskeddropdown’. 2. Places marked in red will receive
update in next build.3. To set value to this object use Custom
operation $(#id).data(maskeddropdown).set()
SearchPage
Advance SearchPage
42© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
11 Page Object Patterns
Case :1. FrontEnd : Html5, third party plugins & Custom plugins2. Database : minimum expected 3 TB data (production)3. Environments: Web browsers, mobile4. Complexity of application under test : Enterprise
Requirement :Over 50-70% of test being automated
Team : Advance test automation users
Pattern 3
43© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
29 May 201943
11 Page Object Patterns
Pattern 3
44© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
User
CPR
First Name
Search
User
User: PageBase
Webelement CPR
Webelement FirstName
Webelement Ok
PageBasePageBase : IWebDriver
- Isloaded()- Get Alert()- Toast Container()- Toast Manage List ()
Page Class
Custom methods()*
* Collection of all methods which could be reused within this page.
Pattern 311 Page Object Patterns
@FindBy(id="firstname")private WebElement firstName;
45© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
User
CPR
First Name
Search
User
User: PageBase
TextBox CPR
TextBox FirstName
Button Ok
PageBasePageBase : IWebDriver
- Isloaded()- Get Alert()- Toast Container()- Toast Manage List ()
Page Class
Custom methods()*
* Collection of all methods which could be reused within this page.
Pattern 311 Page Object Patterns
46© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
User
CPR
First Name
Search
User
User: PageBase
TextBox CPR
TextBox FirstName
Button Ok
PageBasePageBase : IWebDriver
- Isloaded()- Get Alert()- Toast Container()- Toast Manage List ()
Control Class
Control
- Text()- Grid ()- Image()- Accordion()- Span()- Button()- Link()- Table ()
ControlBase- Enabled()- Clickable()- Type()- Click()- Select()
Page Class
Custom methods()*
* Collection of all methods which could be reused within this page.
11 Page Object PatternsPattern 3
:ControlBase
47© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
11 Page Object PatternsPattern 3 – Code walk through
Github : https://github.com/MattManickakumar/TestingTuesday
48© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
11 Page Object Patterns
Pros & Cons
• Increased reusablity• Maintainable• structured development cycle• Robust & flexible to frequent changes
• Planning required• Senior mentorship required during test
design
Test automation challenges
49© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
12 Tips
50© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
12 Tips
51© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
12 Tips
Xpaths
//*[@id="inline-search-collapse"]/form/div[1]/div[1]/div/div/select
//*[@id='inline-search-collapse']//label[text()='Kategori']/..//select
@FindBy(xpath=”.*")private WebElement Kategori;
52© Capgemini 2019. All rights reserved |Presentation Title | Author | Date
Reference
Presentation Model
Supervising Model
Passive view
MVC
MVVM
Reference : https://martinfowler.com/https://www.joecolantonio.com/automation-testing-design-patterns/Book : A Journey through Test Automation Patterns by Sereta Gamba & Dorothy Graham
Inspiration
53© Capgemini 2019. All rights reserved |
Questions
54© Capgemini 2019. All rights reserved | 54© Capgemini 2019. All rights reserved |
Vil du lære mere? Så tag kurset ISTQB Advanced Test Automation
Testautomatisering med LEAPWORK
Andre interessante kurser inden for testautomatisering
Se mere her: https://www.capgemini.dk/Kursuskalender-2018/
A global leader in consulting, technology services and digital transformation,Capgemini is at the forefront of innovation to address the entire breadth of clients’opportunities in the evolving world of cloud, digital and platforms. Building on itsstrong 50-year heritage and deep industry-specific expertise, Capgemini enablesorganizations to realize their business ambitions through an array of services fromstrategy to operations. Capgemini is driven by the conviction that the businessvalue of technology comes from and through people. It is a multicultural companyof over 200,000 team members in more than 40 countries. The Group reported2018 global revenues of EUR 13.2 billion.
About Capgemini
Learn more about us at
www.capgemini.com
This presentation contains information that may be privileged or confidential and is the property of the Capgemini Group.
Copyright © 2019 Capgemini. All rights reserved.
A global leader in consulting, technology services and digital transformation,Capgemini is at the forefront of innovation to address the entire breadth of clients’opportunities in the evolving world of cloud, digital and platforms. Building on itsstrong 50-year heritage and deep industry-specific expertise, Capgemini enablesorganizations to realize their business ambitions through an array of services fromstrategy to operations. Capgemini is driven by the conviction that the business valueof technology comes from and through people. It is a multicultural company of over200,000 team members in more than 40 countries. The Group reported 2018 globalrevenues of EUR 13.2 billion.
About Capgemini
Learn more about us at
www.capgemini.com
This presentation contains information that may be privileged or confidential and is the property of the Capgemini Group.Copyright © 2019 Capgemini. All rights reserved.
Name, Last NameTitle/RoleCapgemini Office (Optional)Address Line 1Address Line 2 Address Line 3
Name, Last NameTitle/RoleCapgemini Office (Optional)Address Line 1Address Line 2 Address Line 3
Name, Last NameTitle/RoleCapgemini Office (Optional)Address Line 1Address Line 2 Address Line 3
Name, Last NameTitle/RoleCapgemini Office (Optional)Address Line 1Address Line 2 Address Line 3
People matter, results count.