SlideShare a Scribd company logo
1 of 29
Adjusting Page-Object approach
for Web Services Test Automation
by Sergey Poritskiy
Presenter
Sergey Poritskiy
Test automation engineer
in EPAM from 2015
projects: Parallels, Datalex
sergey_poritskiy@epam.com
skype: sergey.poritskiy
The goals
After this presentation you will have one more (of first one) practical example
of implementing test automation framework for testing web services, that:
- is easy to understand for you and newcomers
- was implemented on practice and have shown good results
- requires minimal technical expertise from your side
Starting conditions - what did I have
- No test automation on a stream (sub-project)
- Some kind of automation on other streams
- Customer wants BDD + Scrum process
- Some freedom of choice inside the stream
- Junior newcomers
Web services test automation tools and why I didn’t take them
- Custom KDT approach (TAF + Excel)
- SoapUI (SoapUITestCaseRunner for Java)
- JAXB: WSDL (or builder pattern) => POJO
’Classic’ test framework layers in UI test automation
Test scripts
Services
Page-objects
WebDriver
’Classic’ page-object example
public class LoginPage extends Page {
private static final By INPUT_LOGIN_LOCATOR = By.xpath("//input[@name='login']");
private static final By INPUT_PASSWORD_LOCATOR = By.xpath("//input[@name='passwd']");
private static final By BUTTON_SUBMIT_LOCATOR = By.xpath("//span/button[@type='submit']");
public void open() {
driver.get(URL);
}
public void typeUserName(String userName) {
driver.findElement(INPUT_LOGIN_LOCATOR).sendKeys(userName);
}
public void typePassword(String password) {
driver.findElement(INPUT_PASSWORD_LOCATOR).sendKeys(password);
}
public void clickSubmit() {
driver.findElement(BUTTON_SUBMIT_LOCATOR).click();
}
}
Our test framework layers
Test scripts
Step definitions
RX objects
Xml modifier
What is 'RxObject'?
Request / Response
->
Rq / Rs
->
Rx!
Layer 1
Test scripts
Scenarios (Cucumber)
Scenario Outline: Scenario 1 - AirAvailabilityRQ request can be successfully processed
Given User sends AirAvailabilityRQ request with following parameters
| Origin | Destination | Date | AdtQty | ChildQty | InfQty | ClientId |
| <Origin> | <Destination> | 15 | <AdtQty> | <ChildQty> | <InfQty> | <ClientId> |
And User gets successful AirAvailabilityRQ response
And Flight results in AirAvailabilityRQ are not empty
@regression
Examples:
| Origin | Destination | AdtQty | ChildQty | InfQty | ClientId |
| NYC | FRA | 1 | 2 | 0 | LH_A-NYC_MKI-I_US |
| FRA | AMS | 1 | 1 | 1 | LH_A-FRA_MKI-K_DE |
| DXB | NYC | 2 | 1 | 1 | LH_A-DXB_MKI-I_AE |
Layer 2
Step definitions
Step definitions
public class CommonTestSteps {
private RxStore store = RxStore.getInstance();
@Given("^User sends(sw+|)(sw+RQ) request$")
public void userSendsRequest(String rqNumber, String requestType){
Request request = (Request) store.getRxObject(requestType);
store.putRequest(request.getType(), request);
Response response = request.send();
store.putResponse(response.getType(), response, rqNumber);
}
@And("^User gets successful(sw+|) (w+RS)?(?: response|)$")
public void userGetsSuccessResponse(String rsNumber, String responseType) {
Response response = (Response) store.getRxObjectByNumber(responseType, rsNumber);
Assert.assertTrue(response.isSuccessful(), response.getType() + "was not successful!");
}
@And("^(w+) results in(sw+)? (w+RS)(?: response|) are not empty$")
public void resultsNotEmpty(String resultsType, String rsNumber, String responseType) {
Response response = (Response) store.getRxObjectByNumber(responseType, rsNumber);
Assert.assertTrue(response.isResultPresent(resultsType), resultsType + " results are empty!");
}
Layer 3
RX objects
RxObject
public class RxObject {
private String type;
private Document body;
public RxObject(String type, Document body) {
this.type = type;
this.body = body;
}
public String getType() {
return type;
}
public Document getBody() {
return body;
}
public String getNodeValue(String nodeLocator){
return XmlHelper.getNodeText(body, nodeLocator);
}
public boolean isNodePresent(String nodeLocator){
return XmlHelper.isNodePresent(body, nodeLocator);
}
public int getNodesCount(String nodeLocator) {
return XmlHelper.getCountNodesInDocument(body, nodeLocator);
}
}
Request Object
public abstract class Request extends RxObject {
public Request(String requestType) {
super(requestType, XmlHelper.createDocFromFile(NameHelper.getSampleFilePath(requestType)));
}
public abstract void setRequestParameterValue(String nameOfParam, String valueOfParam);
public abstract Response send() throws RequestSendException;
public void changeNodeValue(String locator, String value) {
XmlHelper.changeNodeInDocument(getBody(), locator, value);
}
public void duplicateNode(String locator) {
XmlHelper.duplicateNodeInDocument(getBody(), locator);
}
public void deleteNode(String locator) {
XmlHelper.removeNodeFromDocument(getBody(), locator);
}
}
Response Object
public abstract class Response extends RxObject {
public Response(String type, Document body) {
super(type, body);
}
public abstract boolean isResultPresent(String resultsType);
public abstract String getOfferId();
}
Request Object - dummy (sample)
Request Object - example
public class FunctionalCacheRequest extends Request {
private static final String KEY_LOCATOR = "//Key/text()";
private static final String PRICE_LOCATOR = "//PriceOption/@RateTotalAmount";
public void increaseOfferPrice(int priceCoefficient) {
double newPrice = priceCoefficient + getPrice();
setPrice(String.valueOf(newPrice));
}
public void setPrice(String value) {
changeNodeValue(PRICE_LOCATOR, value);
}
public void setKey(String key) {
changeNodeValue(KEY_LOCATOR, key);
}
public double getPrice() {
return Double.parseDoube(XmlHelper.getNodeText(getBody(), PRICE_LOCATOR));
}
@Override
public FunctionalCacheResponse send() {
return new FunctionalCacheResponse(SoapSender.sendXmlRequest(this));
}
Response Object - example
public class FunctionalCacheResponse extends Response implements HavingOfferPrice {
private static final String MESSAGE_LOCATOR = "//Message/text()";
private static final String ERROR_LOCATOR = "//Error/text()";
private static final String PRICE_LOCATOR = "//PriceOption/@RateTotalAmount";
private static final String OFFER_ID_LOCATOR = "//OfferId";
public String getMessageText() {
return getNodeValue(MESSAGE_LOCATOR);
}
public String getErrorText() {
return getNodeValue(ERROR_LOCATOR);
}
public double getOfferPrice() {
return Double.parseDouble(getNodeValue(PRICE_LOCATOR));
}
public String getOfferId() {
return getNodeValue(OFFER_ID_LOCATOR);
}
}
Layer 4
Xml modifier
XmlHelper
public class XmlHelper {
private static final String NODE_NAME_REGEX =
"(?<!['"][w/-]{1,255})(?<=[(/[:]|(and|or)s)[a-z_]+b(?![(':-])";
private static final String FORMATTING_PATTERN = "*[local-name()='%s']";
private static String makeXpathLocatorNameSpaceIgnoring(String xpathLocator) {…}
private static NodeList getNodeListByXpath(Document doc, String locator) {…}
private static Node getXmlNodeByXpath(Document doc, String locator) {…}
public static boolean isNodePresent(Document doc, String locator) {…}
public static String getNodeText(Document doc, String locator) {…}
public static void changeNodeInDocument(Document doc, String locator, String value) {…}
public static int countNodesInDocument(Document doc, String locator) {…}
public static void removeNodeFromDocument(Document doc, String locator) {…}
public static void duplicateNodeInDocument(Document doc, String locator) {…}
...
...
...
Benefits of this approach
- very simple to understand, read and write tests (KISS principle)
- has lower entrance level
- friendly for automation engineers without experience in web services testing
- doesn’t need WSDL’s that are not always available
- was successfully implemented on real project and shows good results
Questions, contacts
Questions?
sergey_poritskiy@epam.com
skype: sergey.poritskiy
MY CONTACTS
Sergey_Poritskiy@epam.com
sergey.poritskiy
Thanks!
Thanks!
Thanks!
Secret page!!!

More Related Content

What's hot

Codecamp iasi-26 nov 2011-what's new in jpa 2.0
Codecamp iasi-26 nov 2011-what's new in jpa 2.0Codecamp iasi-26 nov 2011-what's new in jpa 2.0
Codecamp iasi-26 nov 2011-what's new in jpa 2.0Codecamp Romania
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator OverloadingNilesh Dalvi
 
C# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsC# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsMohammad Shaker
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overviewgourav kottawar
 
Enterprise State Management with NGRX/platform
Enterprise State Management with NGRX/platformEnterprise State Management with NGRX/platform
Enterprise State Management with NGRX/platformIlia Idakiev
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingKumar
 
Lec 26.27-operator overloading
Lec 26.27-operator overloadingLec 26.27-operator overloading
Lec 26.27-operator overloadingPrincess Sam
 
Operator overloading and type conversions
Operator overloading and type conversionsOperator overloading and type conversions
Operator overloading and type conversionsAmogh Kalyanshetti
 
04. constructor & destructor
04. constructor & destructor04. constructor & destructor
04. constructor & destructorHaresh Jaiswal
 
Operator overloading and type conversion in cpp
Operator overloading and type conversion in cppOperator overloading and type conversion in cpp
Operator overloading and type conversion in cpprajshreemuthiah
 
Functional programming in Javascript
Functional programming in JavascriptFunctional programming in Javascript
Functional programming in JavascriptKnoldus Inc.
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingKamal Acharya
 

What's hot (20)

Codecamp iasi-26 nov 2011-what's new in jpa 2.0
Codecamp iasi-26 nov 2011-what's new in jpa 2.0Codecamp iasi-26 nov 2011-what's new in jpa 2.0
Codecamp iasi-26 nov 2011-what's new in jpa 2.0
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
C# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension MethodsC# Starter L06-Delegates, Event Handling and Extension Methods
C# Starter L06-Delegates, Event Handling and Extension Methods
 
Hems
HemsHems
Hems
 
Unary operator overloading
Unary operator overloadingUnary operator overloading
Unary operator overloading
 
Tolog Updates
Tolog UpdatesTolog Updates
Tolog Updates
 
JavaScript Core
JavaScript CoreJavaScript Core
JavaScript Core
 
Linq
LinqLinq
Linq
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overview
 
Enterprise State Management with NGRX/platform
Enterprise State Management with NGRX/platformEnterprise State Management with NGRX/platform
Enterprise State Management with NGRX/platform
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Lec 26.27-operator overloading
Lec 26.27-operator overloadingLec 26.27-operator overloading
Lec 26.27-operator overloading
 
Operator overloading and type conversions
Operator overloading and type conversionsOperator overloading and type conversions
Operator overloading and type conversions
 
Anonymous functions in JavaScript
Anonymous functions in JavaScriptAnonymous functions in JavaScript
Anonymous functions in JavaScript
 
Cocoa heads 09112017
Cocoa heads 09112017Cocoa heads 09112017
Cocoa heads 09112017
 
04. constructor & destructor
04. constructor & destructor04. constructor & destructor
04. constructor & destructor
 
Operator overloading and type conversion in cpp
Operator overloading and type conversion in cppOperator overloading and type conversion in cpp
Operator overloading and type conversion in cpp
 
LINQ
LINQLINQ
LINQ
 
Functional programming in Javascript
Functional programming in JavascriptFunctional programming in Javascript
Functional programming in Javascript
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 

Similar to Применение паттерна Page Object для автоматизации веб сервисов

Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsGuy Nir
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every dayVadym Khondar
 
Easy rest service using PHP reflection api
Easy rest service using PHP reflection apiEasy rest service using PHP reflection api
Easy rest service using PHP reflection apiMatthieu Aubry
 
PHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generationPHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generationAlexander Obukhov
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC AnnotationsJordan Silva
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy codeShriKant Vashishtha
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIEyal Vardi
 
Тарас Олексин - Sculpt! Your! Tests!
Тарас Олексин  - Sculpt! Your! Tests!Тарас Олексин  - Sculpt! Your! Tests!
Тарас Олексин - Sculpt! Your! Tests!DataArt
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014hezamu
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09Daniel Bryant
 
Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010Michelangelo van Dam
 
Testing in android
Testing in androidTesting in android
Testing in androidjtrindade
 
Taming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, MacoscopeTaming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, MacoscopeMacoscope
 
Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented NetworkingMostafa Amer
 

Similar to Применение паттерна Page Object для автоматизации веб сервисов (20)

Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Codemotion appengine
Codemotion appengineCodemotion appengine
Codemotion appengine
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
Easy rest service using PHP reflection api
Easy rest service using PHP reflection apiEasy rest service using PHP reflection api
Easy rest service using PHP reflection api
 
PHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generationPHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generation
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
 
Working effectively with legacy code
Working effectively with legacy codeWorking effectively with legacy code
Working effectively with legacy code
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web API
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Тарас Олексин - Sculpt! Your! Tests!
Тарас Олексин  - Sculpt! Your! Tests!Тарас Олексин  - Sculpt! Your! Tests!
Тарас Олексин - Sculpt! Your! Tests!
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014
 
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09L2 Web App Development Guest Lecture At University of Surrey 20/11/09
L2 Web App Development Guest Lecture At University of Surrey 20/11/09
 
Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010Advanced Php - Macq Electronique 2010
Advanced Php - Macq Electronique 2010
 
Testing in android
Testing in androidTesting in android
Testing in android
 
Taming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, MacoscopeTaming Core Data by Arek Holko, Macoscope
Taming Core Data by Arek Holko, Macoscope
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
Protocol-Oriented Networking
Protocol-Oriented NetworkingProtocol-Oriented Networking
Protocol-Oriented Networking
 

More from COMAQA.BY

Тестирование аналогов инсталлируемых приложений (Android Instant Apps, Progre...
Тестирование аналогов инсталлируемых приложений (Android Instant Apps, Progre...Тестирование аналогов инсталлируемых приложений (Android Instant Apps, Progre...
Тестирование аналогов инсталлируемых приложений (Android Instant Apps, Progre...COMAQA.BY
 
Anton semenchenko. Comaqa Spring 2018. Nine circles of hell. Antipatterns in ...
Anton semenchenko. Comaqa Spring 2018. Nine circles of hell. Antipatterns in ...Anton semenchenko. Comaqa Spring 2018. Nine circles of hell. Antipatterns in ...
Anton semenchenko. Comaqa Spring 2018. Nine circles of hell. Antipatterns in ...COMAQA.BY
 
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...COMAQA.BY
 
Roman Soroka. Comaqa Spring 2018. Глобальный обзор процесса QA и его важность
Roman Soroka. Comaqa Spring 2018. Глобальный обзор процесса QA и его важностьRoman Soroka. Comaqa Spring 2018. Глобальный обзор процесса QA и его важность
Roman Soroka. Comaqa Spring 2018. Глобальный обзор процесса QA и его важностьCOMAQA.BY
 
Roman Iovlev. Comaqa Spring 2018. Архитектура Open Source решений для автомат...
Roman Iovlev. Comaqa Spring 2018. Архитектура Open Source решений для автомат...Roman Iovlev. Comaqa Spring 2018. Архитектура Open Source решений для автомат...
Roman Iovlev. Comaqa Spring 2018. Архитектура Open Source решений для автомат...COMAQA.BY
 
Vladimir Polyakov. Comaqa Spring 2018. Особенности тестирования ПО в предметн...
Vladimir Polyakov. Comaqa Spring 2018. Особенности тестирования ПО в предметн...Vladimir Polyakov. Comaqa Spring 2018. Особенности тестирования ПО в предметн...
Vladimir Polyakov. Comaqa Spring 2018. Особенности тестирования ПО в предметн...COMAQA.BY
 
Kimmo Hakala. Comaqa Spring 2018. Challenges and good QA practices in softwar...
Kimmo Hakala. Comaqa Spring 2018. Challenges and good QA practices in softwar...Kimmo Hakala. Comaqa Spring 2018. Challenges and good QA practices in softwar...
Kimmo Hakala. Comaqa Spring 2018. Challenges and good QA practices in softwar...COMAQA.BY
 
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...COMAQA.BY
 
Ivan Katunov. Comaqa Spring 2018. Test Design and Automation for Rest API.
Ivan Katunov. Comaqa Spring 2018. Test Design and Automation for Rest API.Ivan Katunov. Comaqa Spring 2018. Test Design and Automation for Rest API.
Ivan Katunov. Comaqa Spring 2018. Test Design and Automation for Rest API.COMAQA.BY
 
Vadim Zubovich. Comaqa Spring 2018. Красивое тестирование производительности.
Vadim Zubovich. Comaqa Spring 2018. Красивое тестирование производительности.Vadim Zubovich. Comaqa Spring 2018. Красивое тестирование производительности.
Vadim Zubovich. Comaqa Spring 2018. Красивое тестирование производительности.COMAQA.BY
 
Alexander Andelkovic. Comaqa Spring 2018. Using Artificial Intelligence to Te...
Alexander Andelkovic. Comaqa Spring 2018. Using Artificial Intelligence to Te...Alexander Andelkovic. Comaqa Spring 2018. Using Artificial Intelligence to Te...
Alexander Andelkovic. Comaqa Spring 2018. Using Artificial Intelligence to Te...COMAQA.BY
 
Моя роль в конфликте
Моя роль в конфликтеМоя роль в конфликте
Моя роль в конфликтеCOMAQA.BY
 
Организация приемочного тестирования силами матерых тестировщиков
Организация приемочного тестирования силами матерых тестировщиковОрганизация приемочного тестирования силами матерых тестировщиков
Организация приемочного тестирования силами матерых тестировщиковCOMAQA.BY
 
Развитие или смерть
Развитие или смертьРазвитие или смерть
Развитие или смертьCOMAQA.BY
 
Системный взгляд на параллельный запуск Selenium тестов
Системный взгляд на параллельный запуск Selenium тестовСистемный взгляд на параллельный запуск Selenium тестов
Системный взгляд на параллельный запуск Selenium тестовCOMAQA.BY
 
Эффективная работа с рутинными задачами
Эффективная работа с рутинными задачамиЭффективная работа с рутинными задачами
Эффективная работа с рутинными задачамиCOMAQA.BY
 
Как стать синьором
Как стать синьоромКак стать синьором
Как стать синьоромCOMAQA.BY
 
Open your mind for OpenSource
Open your mind for OpenSourceOpen your mind for OpenSource
Open your mind for OpenSourceCOMAQA.BY
 
JDI 2.0. Not only UI testing
JDI 2.0. Not only UI testingJDI 2.0. Not only UI testing
JDI 2.0. Not only UI testingCOMAQA.BY
 
Out of box page object design pattern, java
Out of box page object design pattern, javaOut of box page object design pattern, java
Out of box page object design pattern, javaCOMAQA.BY
 

More from COMAQA.BY (20)

Тестирование аналогов инсталлируемых приложений (Android Instant Apps, Progre...
Тестирование аналогов инсталлируемых приложений (Android Instant Apps, Progre...Тестирование аналогов инсталлируемых приложений (Android Instant Apps, Progre...
Тестирование аналогов инсталлируемых приложений (Android Instant Apps, Progre...
 
Anton semenchenko. Comaqa Spring 2018. Nine circles of hell. Antipatterns in ...
Anton semenchenko. Comaqa Spring 2018. Nine circles of hell. Antipatterns in ...Anton semenchenko. Comaqa Spring 2018. Nine circles of hell. Antipatterns in ...
Anton semenchenko. Comaqa Spring 2018. Nine circles of hell. Antipatterns in ...
 
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
Vivien Ibironke Ibiyemi. Comaqa Spring 2018. Enhance your Testing Skills With...
 
Roman Soroka. Comaqa Spring 2018. Глобальный обзор процесса QA и его важность
Roman Soroka. Comaqa Spring 2018. Глобальный обзор процесса QA и его важностьRoman Soroka. Comaqa Spring 2018. Глобальный обзор процесса QA и его важность
Roman Soroka. Comaqa Spring 2018. Глобальный обзор процесса QA и его важность
 
Roman Iovlev. Comaqa Spring 2018. Архитектура Open Source решений для автомат...
Roman Iovlev. Comaqa Spring 2018. Архитектура Open Source решений для автомат...Roman Iovlev. Comaqa Spring 2018. Архитектура Open Source решений для автомат...
Roman Iovlev. Comaqa Spring 2018. Архитектура Open Source решений для автомат...
 
Vladimir Polyakov. Comaqa Spring 2018. Особенности тестирования ПО в предметн...
Vladimir Polyakov. Comaqa Spring 2018. Особенности тестирования ПО в предметн...Vladimir Polyakov. Comaqa Spring 2018. Особенности тестирования ПО в предметн...
Vladimir Polyakov. Comaqa Spring 2018. Особенности тестирования ПО в предметн...
 
Kimmo Hakala. Comaqa Spring 2018. Challenges and good QA practices in softwar...
Kimmo Hakala. Comaqa Spring 2018. Challenges and good QA practices in softwar...Kimmo Hakala. Comaqa Spring 2018. Challenges and good QA practices in softwar...
Kimmo Hakala. Comaqa Spring 2018. Challenges and good QA practices in softwar...
 
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
 
Ivan Katunov. Comaqa Spring 2018. Test Design and Automation for Rest API.
Ivan Katunov. Comaqa Spring 2018. Test Design and Automation for Rest API.Ivan Katunov. Comaqa Spring 2018. Test Design and Automation for Rest API.
Ivan Katunov. Comaqa Spring 2018. Test Design and Automation for Rest API.
 
Vadim Zubovich. Comaqa Spring 2018. Красивое тестирование производительности.
Vadim Zubovich. Comaqa Spring 2018. Красивое тестирование производительности.Vadim Zubovich. Comaqa Spring 2018. Красивое тестирование производительности.
Vadim Zubovich. Comaqa Spring 2018. Красивое тестирование производительности.
 
Alexander Andelkovic. Comaqa Spring 2018. Using Artificial Intelligence to Te...
Alexander Andelkovic. Comaqa Spring 2018. Using Artificial Intelligence to Te...Alexander Andelkovic. Comaqa Spring 2018. Using Artificial Intelligence to Te...
Alexander Andelkovic. Comaqa Spring 2018. Using Artificial Intelligence to Te...
 
Моя роль в конфликте
Моя роль в конфликтеМоя роль в конфликте
Моя роль в конфликте
 
Организация приемочного тестирования силами матерых тестировщиков
Организация приемочного тестирования силами матерых тестировщиковОрганизация приемочного тестирования силами матерых тестировщиков
Организация приемочного тестирования силами матерых тестировщиков
 
Развитие или смерть
Развитие или смертьРазвитие или смерть
Развитие или смерть
 
Системный взгляд на параллельный запуск Selenium тестов
Системный взгляд на параллельный запуск Selenium тестовСистемный взгляд на параллельный запуск Selenium тестов
Системный взгляд на параллельный запуск Selenium тестов
 
Эффективная работа с рутинными задачами
Эффективная работа с рутинными задачамиЭффективная работа с рутинными задачами
Эффективная работа с рутинными задачами
 
Как стать синьором
Как стать синьоромКак стать синьором
Как стать синьором
 
Open your mind for OpenSource
Open your mind for OpenSourceOpen your mind for OpenSource
Open your mind for OpenSource
 
JDI 2.0. Not only UI testing
JDI 2.0. Not only UI testingJDI 2.0. Not only UI testing
JDI 2.0. Not only UI testing
 
Out of box page object design pattern, java
Out of box page object design pattern, javaOut of box page object design pattern, java
Out of box page object design pattern, java
 

Recently uploaded

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Применение паттерна Page Object для автоматизации веб сервисов

  • 1. Adjusting Page-Object approach for Web Services Test Automation by Sergey Poritskiy
  • 2. Presenter Sergey Poritskiy Test automation engineer in EPAM from 2015 projects: Parallels, Datalex sergey_poritskiy@epam.com skype: sergey.poritskiy
  • 3. The goals After this presentation you will have one more (of first one) practical example of implementing test automation framework for testing web services, that: - is easy to understand for you and newcomers - was implemented on practice and have shown good results - requires minimal technical expertise from your side
  • 4. Starting conditions - what did I have - No test automation on a stream (sub-project) - Some kind of automation on other streams - Customer wants BDD + Scrum process - Some freedom of choice inside the stream - Junior newcomers
  • 5. Web services test automation tools and why I didn’t take them - Custom KDT approach (TAF + Excel) - SoapUI (SoapUITestCaseRunner for Java) - JAXB: WSDL (or builder pattern) => POJO
  • 6. ’Classic’ test framework layers in UI test automation Test scripts Services Page-objects WebDriver
  • 7. ’Classic’ page-object example public class LoginPage extends Page { private static final By INPUT_LOGIN_LOCATOR = By.xpath("//input[@name='login']"); private static final By INPUT_PASSWORD_LOCATOR = By.xpath("//input[@name='passwd']"); private static final By BUTTON_SUBMIT_LOCATOR = By.xpath("//span/button[@type='submit']"); public void open() { driver.get(URL); } public void typeUserName(String userName) { driver.findElement(INPUT_LOGIN_LOCATOR).sendKeys(userName); } public void typePassword(String password) { driver.findElement(INPUT_PASSWORD_LOCATOR).sendKeys(password); } public void clickSubmit() { driver.findElement(BUTTON_SUBMIT_LOCATOR).click(); } }
  • 8. Our test framework layers Test scripts Step definitions RX objects Xml modifier
  • 9. What is 'RxObject'? Request / Response -> Rq / Rs -> Rx!
  • 11. Scenarios (Cucumber) Scenario Outline: Scenario 1 - AirAvailabilityRQ request can be successfully processed Given User sends AirAvailabilityRQ request with following parameters | Origin | Destination | Date | AdtQty | ChildQty | InfQty | ClientId | | <Origin> | <Destination> | 15 | <AdtQty> | <ChildQty> | <InfQty> | <ClientId> | And User gets successful AirAvailabilityRQ response And Flight results in AirAvailabilityRQ are not empty @regression Examples: | Origin | Destination | AdtQty | ChildQty | InfQty | ClientId | | NYC | FRA | 1 | 2 | 0 | LH_A-NYC_MKI-I_US | | FRA | AMS | 1 | 1 | 1 | LH_A-FRA_MKI-K_DE | | DXB | NYC | 2 | 1 | 1 | LH_A-DXB_MKI-I_AE |
  • 13. Step definitions public class CommonTestSteps { private RxStore store = RxStore.getInstance(); @Given("^User sends(sw+|)(sw+RQ) request$") public void userSendsRequest(String rqNumber, String requestType){ Request request = (Request) store.getRxObject(requestType); store.putRequest(request.getType(), request); Response response = request.send(); store.putResponse(response.getType(), response, rqNumber); } @And("^User gets successful(sw+|) (w+RS)?(?: response|)$") public void userGetsSuccessResponse(String rsNumber, String responseType) { Response response = (Response) store.getRxObjectByNumber(responseType, rsNumber); Assert.assertTrue(response.isSuccessful(), response.getType() + "was not successful!"); } @And("^(w+) results in(sw+)? (w+RS)(?: response|) are not empty$") public void resultsNotEmpty(String resultsType, String rsNumber, String responseType) { Response response = (Response) store.getRxObjectByNumber(responseType, rsNumber); Assert.assertTrue(response.isResultPresent(resultsType), resultsType + " results are empty!"); }
  • 15. RxObject public class RxObject { private String type; private Document body; public RxObject(String type, Document body) { this.type = type; this.body = body; } public String getType() { return type; } public Document getBody() { return body; } public String getNodeValue(String nodeLocator){ return XmlHelper.getNodeText(body, nodeLocator); } public boolean isNodePresent(String nodeLocator){ return XmlHelper.isNodePresent(body, nodeLocator); } public int getNodesCount(String nodeLocator) { return XmlHelper.getCountNodesInDocument(body, nodeLocator); } }
  • 16. Request Object public abstract class Request extends RxObject { public Request(String requestType) { super(requestType, XmlHelper.createDocFromFile(NameHelper.getSampleFilePath(requestType))); } public abstract void setRequestParameterValue(String nameOfParam, String valueOfParam); public abstract Response send() throws RequestSendException; public void changeNodeValue(String locator, String value) { XmlHelper.changeNodeInDocument(getBody(), locator, value); } public void duplicateNode(String locator) { XmlHelper.duplicateNodeInDocument(getBody(), locator); } public void deleteNode(String locator) { XmlHelper.removeNodeFromDocument(getBody(), locator); } }
  • 17. Response Object public abstract class Response extends RxObject { public Response(String type, Document body) { super(type, body); } public abstract boolean isResultPresent(String resultsType); public abstract String getOfferId(); }
  • 18. Request Object - dummy (sample)
  • 19. Request Object - example public class FunctionalCacheRequest extends Request { private static final String KEY_LOCATOR = "//Key/text()"; private static final String PRICE_LOCATOR = "//PriceOption/@RateTotalAmount"; public void increaseOfferPrice(int priceCoefficient) { double newPrice = priceCoefficient + getPrice(); setPrice(String.valueOf(newPrice)); } public void setPrice(String value) { changeNodeValue(PRICE_LOCATOR, value); } public void setKey(String key) { changeNodeValue(KEY_LOCATOR, key); } public double getPrice() { return Double.parseDoube(XmlHelper.getNodeText(getBody(), PRICE_LOCATOR)); } @Override public FunctionalCacheResponse send() { return new FunctionalCacheResponse(SoapSender.sendXmlRequest(this)); }
  • 20. Response Object - example public class FunctionalCacheResponse extends Response implements HavingOfferPrice { private static final String MESSAGE_LOCATOR = "//Message/text()"; private static final String ERROR_LOCATOR = "//Error/text()"; private static final String PRICE_LOCATOR = "//PriceOption/@RateTotalAmount"; private static final String OFFER_ID_LOCATOR = "//OfferId"; public String getMessageText() { return getNodeValue(MESSAGE_LOCATOR); } public String getErrorText() { return getNodeValue(ERROR_LOCATOR); } public double getOfferPrice() { return Double.parseDouble(getNodeValue(PRICE_LOCATOR)); } public String getOfferId() { return getNodeValue(OFFER_ID_LOCATOR); } }
  • 22. XmlHelper public class XmlHelper { private static final String NODE_NAME_REGEX = "(?<!['"][w/-]{1,255})(?<=[(/[:]|(and|or)s)[a-z_]+b(?![(':-])"; private static final String FORMATTING_PATTERN = "*[local-name()='%s']"; private static String makeXpathLocatorNameSpaceIgnoring(String xpathLocator) {…} private static NodeList getNodeListByXpath(Document doc, String locator) {…} private static Node getXmlNodeByXpath(Document doc, String locator) {…} public static boolean isNodePresent(Document doc, String locator) {…} public static String getNodeText(Document doc, String locator) {…} public static void changeNodeInDocument(Document doc, String locator, String value) {…} public static int countNodesInDocument(Document doc, String locator) {…} public static void removeNodeFromDocument(Document doc, String locator) {…} public static void duplicateNodeInDocument(Document doc, String locator) {…} ... ... ...
  • 23. Benefits of this approach - very simple to understand, read and write tests (KISS principle) - has lower entrance level - friendly for automation engineers without experience in web services testing - doesn’t need WSDL’s that are not always available - was successfully implemented on real project and shows good results