SlideShare a Scribd company logo
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
What should you know before (or should have heard about)
- Test automation
- Basic TA framework layers
- Page object pattern/approach
- Web services (SOAP/REST)
- XML
- XPath
- BDD approach and Gherkin language (Cucumber, JBehave)
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 implement
- is easy to understand by newcomers
- was implemented on practice and have shown good results
Starting conditions
- No test automation on a stream (sub-project)
- Need to test SOAP services, air travel domain
- A LOT of business objects and entities
- Customer wants Cucumber
- Junior newcomers are planned
The questions will TA Engineers have
- How to automate SOAP services testing?
- Let’s google it! Em… SoapUI?.. Is it something else?
- How to operate requests/responses?
- Object model?
- Write all the objects?
- Generate them?
What sounds more familiar for all of us
!!!
’Classic’ test framework structure in UI test automation
Test scripts
Services/steps
Page-objects
WebDriver
Utils
Loggers
Stuff
’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
Utils
Loggers
Stuff
What is 'RxObject'?
Request / Response
->
Rq / Rs
->
Rx!
Layer 1
Test scripts
Step definitions
Rx-objects
Xml Modifier
Scenarios (Cucumber) – make your own DSL
Scenario Outline: Scenario 1 - AirAvailabilityRQ request can be successfully processed
Given User sends FlightSearchRQ request with following parameters
| Origin | Destination | Date | AdtQty | ChildQty | InfQty | ClientId |
| <Origin> | <Destination> | 15 | <AdtQty> | <ChildQty> | <InfQty> | <ClientId> |
And User gets successful FlightSearchRS response
And Flight results in FlightSearchRS are not empty
When User sends BookingRQ request with OfferId from FlightSearchRS response
Then User gets successful BookingRS response
@smoke
Examples:
| Origin | Destination | AdtQty | ChildQty | InfQty | ClientId |
| NYC | FRA | 1 | 0 | 0 | LH_A-NYC |
@regression
Examples:
| Origin | Destination | AdtQty | ChildQty | InfQty | ClientId |
| NYC | FRA | 1 | 2 | 0 | LH_A-NYC |
| FRA | AMS | 1 | 1 | 1 | LH_A-FRA |
| DXB | NYC | 2 | 1 | 1 | LH_A-DXB |
Layer 2
Test scripts
Step definitions
Rx-objects
Xml Modifier
Step definitions
public class CommonTestSteps {
@Given("^User sends(sw+|)(sw+RQ) request$")
public void userSendsRequest(String rqNumber, String requestType){
Request request = RequestFactory.createRequest(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 = store.getResponse(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 = store.getResponse(responseType, rsNumber);
Assert.assertTrue(response.isResultPresent(resultsType), resultsType + " results are empty!");
}
Layer 3
Test scripts
Step definitions
Rx-objects
Xml Modifier
Rx objects hierarchy
RxObject
(has type and body)
Request
(modifies its body)
FlightSearchRequest
Response
(read-only)
FlightSearchResponse… … … … …
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);
}
...
}
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 priceToAdd) {
double newPrice = priceToAdd + 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.sendRequest(this));
}
Request body - dummy (sample)
Response Object
public abstract class Response extends RxObject {
public Response(String type, Document body) {
super(type, body);
}
public abstract boolean isSuccessfull();
public abstract boolean isResultPresent(String resultsType);
public abstract String getOfferId();
...
}
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
Test scripts
Step definitions
Rx-objects
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 getNodeByXpath(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 (pure KISS principle)
- has lower entrance level
- friendly for automation engineers without experience in web services testing
- can be good option when you have a lot of business objects and entities
- was successfully implemented on real project and shows good results
Can we use RxObject for testing REST services?
In theory – yes.
public class RxObject {
private String type;
private Something body;
private String format;
private String responseFormat;
private String httpMethod;
...
...
...
}
But this will be more complicated.
Also you can take Rest Assured or other rest-automating framework.
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

JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
WebStackAcademy
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
Mindfire Solutions
 
Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....
Raffi Krikorian
 
ConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with Groovy
Iván López Martín
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
Van Huong
 
Google Dart
Google DartGoogle Dart
Google Dart
Eberhard Wolff
 
JavaScript Data Types
JavaScript Data TypesJavaScript Data Types
JavaScript Data Types
Charles Russell
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
Bala Narayanan
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
Mats Bryntse
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypesVarun C M
 
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Hardik Trivedi
 
Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)
Adam Mukharil Bachtiar
 
Java 8
Java 8Java 8
Java 8: the good parts!
Java 8: the good parts!Java 8: the good parts!
Java 8: the good parts!
Andrzej Grzesik
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
Fu Cheng
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
Ruslan Shevchenko
 
javascript objects
javascript objectsjavascript objects
javascript objects
Vijay Kalyan
 
Java8
Java8Java8
Amber and beyond: Java language changes
Amber and beyond: Java language changesAmber and beyond: Java language changes
Amber and beyond: Java language changes
Stephen Colebourne
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Anna Brzezińska
 

What's hot (20)

JavaScript - Chapter 4 - Types and Statements
 JavaScript - Chapter 4 - Types and Statements JavaScript - Chapter 4 - Types and Statements
JavaScript - Chapter 4 - Types and Statements
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 
Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....
 
ConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with Groovy
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Google Dart
Google DartGoogle Dart
Google Dart
 
JavaScript Data Types
JavaScript Data TypesJavaScript Data Types
JavaScript Data Types
 
Basics of JavaScript
Basics of JavaScriptBasics of JavaScript
Basics of JavaScript
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
 
Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)Algorithm and Programming (Looping Structure)
Algorithm and Programming (Looping Structure)
 
Java 8
Java 8Java 8
Java 8
 
Java 8: the good parts!
Java 8: the good parts!Java 8: the good parts!
Java 8: the good parts!
 
Advanced JavaScript
Advanced JavaScriptAdvanced JavaScript
Advanced JavaScript
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
 
javascript objects
javascript objectsjavascript objects
javascript objects
 
Java8
Java8Java8
Java8
 
Amber and beyond: Java language changes
Amber and beyond: Java language changesAmber and beyond: Java language changes
Amber and beyond: Java language changes
 
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24  tricky stuff in java grammar and javacJug trojmiasto 2014.04.24  tricky stuff in java grammar and javac
Jug trojmiasto 2014.04.24 tricky stuff in java grammar and javac
 

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

Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationAjax Experience 2009
 
PHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generationPHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generation
Alexander Obukhov
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
Roberto Suggi Liverani
 
Dynamics 365 CRM Javascript Customization
Dynamics 365 CRM Javascript CustomizationDynamics 365 CRM Javascript Customization
Dynamics 365 CRM Javascript Customization
Sanjaya Prakash Pradhan
 
Tk2323 lecture 9 api json
Tk2323 lecture 9   api jsonTk2323 lecture 9   api json
Tk2323 lecture 9 api json
MengChun Lam
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
GeorgePeterBanyard
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
Jordan Silva
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5
Martin Kleppe
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
Vadym Khondar
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
Alena Holligan
 
Ajax Fundamentals Web Applications
Ajax Fundamentals Web ApplicationsAjax Fundamentals Web Applications
Ajax Fundamentals Web Applicationsdominion
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimizedWoody Pewitt
 
Lambda Chops - Recipes for Simpler, More Expressive Code
Lambda Chops - Recipes for Simpler, More Expressive CodeLambda Chops - Recipes for Simpler, More Expressive Code
Lambda Chops - Recipes for Simpler, More Expressive Code
Ian Robertson
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
nbuddharaju
 
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngineGoogle Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Roman Kirillov
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
stephskardal
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
Sam Brannen
 
Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13
Jason Lotito
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
HamletDRC
 

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

Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus Presentation
 
PHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generationPHP: GraphQL consistency through code generation
PHP: GraphQL consistency through code generation
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
Dynamics 365 CRM Javascript Customization
Dynamics 365 CRM Javascript CustomizationDynamics 365 CRM Javascript Customization
Dynamics 365 CRM Javascript Customization
 
Tk2323 lecture 9 api json
Tk2323 lecture 9   api jsonTk2323 lecture 9   api json
Tk2323 lecture 9 api json
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
 
What's new in jQuery 1.5
What's new in jQuery 1.5What's new in jQuery 1.5
What's new in jQuery 1.5
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Ajax Fundamentals Web Applications
Ajax Fundamentals Web ApplicationsAjax Fundamentals Web Applications
Ajax Fundamentals Web Applications
 
Is your C# optimized
Is your C# optimizedIs your C# optimized
Is your C# optimized
 
Lambda Chops - Recipes for Simpler, More Expressive Code
Lambda Chops - Recipes for Simpler, More Expressive CodeLambda Chops - Recipes for Simpler, More Expressive Code
Lambda Chops - Recipes for Simpler, More Expressive Code
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngineGoogle Cloud Endpoints: Building Third-Party APIs on Google AppEngine
Google Cloud Endpoints: Building Third-Party APIs on Google AppEngine
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13Load Testing with PHP and RedLine13
Load Testing with PHP and RedLine13
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 

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 OpenSource
COMAQA.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 testing
COMAQA.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, java
COMAQA.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

Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 

Recently uploaded (20)

Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 

Применение паттерна 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. What should you know before (or should have heard about) - Test automation - Basic TA framework layers - Page object pattern/approach - Web services (SOAP/REST) - XML - XPath - BDD approach and Gherkin language (Cucumber, JBehave)
  • 4. 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 implement - is easy to understand by newcomers - was implemented on practice and have shown good results
  • 5. Starting conditions - No test automation on a stream (sub-project) - Need to test SOAP services, air travel domain - A LOT of business objects and entities - Customer wants Cucumber - Junior newcomers are planned
  • 6. The questions will TA Engineers have - How to automate SOAP services testing? - Let’s google it! Em… SoapUI?.. Is it something else? - How to operate requests/responses? - Object model? - Write all the objects? - Generate them?
  • 7. What sounds more familiar for all of us !!!
  • 8. ’Classic’ test framework structure in UI test automation Test scripts Services/steps Page-objects WebDriver Utils Loggers Stuff
  • 9. ’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(); } }
  • 10. Our test framework layers Test scripts Step definitions Rx-objects Xml Modifier Utils Loggers Stuff
  • 11. What is 'RxObject'? Request / Response -> Rq / Rs -> Rx!
  • 12. Layer 1 Test scripts Step definitions Rx-objects Xml Modifier
  • 13. Scenarios (Cucumber) – make your own DSL Scenario Outline: Scenario 1 - AirAvailabilityRQ request can be successfully processed Given User sends FlightSearchRQ request with following parameters | Origin | Destination | Date | AdtQty | ChildQty | InfQty | ClientId | | <Origin> | <Destination> | 15 | <AdtQty> | <ChildQty> | <InfQty> | <ClientId> | And User gets successful FlightSearchRS response And Flight results in FlightSearchRS are not empty When User sends BookingRQ request with OfferId from FlightSearchRS response Then User gets successful BookingRS response @smoke Examples: | Origin | Destination | AdtQty | ChildQty | InfQty | ClientId | | NYC | FRA | 1 | 0 | 0 | LH_A-NYC | @regression Examples: | Origin | Destination | AdtQty | ChildQty | InfQty | ClientId | | NYC | FRA | 1 | 2 | 0 | LH_A-NYC | | FRA | AMS | 1 | 1 | 1 | LH_A-FRA | | DXB | NYC | 2 | 1 | 1 | LH_A-DXB |
  • 14. Layer 2 Test scripts Step definitions Rx-objects Xml Modifier
  • 15. Step definitions public class CommonTestSteps { @Given("^User sends(sw+|)(sw+RQ) request$") public void userSendsRequest(String rqNumber, String requestType){ Request request = RequestFactory.createRequest(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 = store.getResponse(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 = store.getResponse(responseType, rsNumber); Assert.assertTrue(response.isResultPresent(resultsType), resultsType + " results are empty!"); }
  • 16. Layer 3 Test scripts Step definitions Rx-objects Xml Modifier
  • 17. Rx objects hierarchy RxObject (has type and body) Request (modifies its body) FlightSearchRequest Response (read-only) FlightSearchResponse… … … … …
  • 18. 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); } ... }
  • 19. 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); } ... }
  • 20. 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 priceToAdd) { double newPrice = priceToAdd + 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.sendRequest(this)); }
  • 21. Request body - dummy (sample)
  • 22. Response Object public abstract class Response extends RxObject { public Response(String type, Document body) { super(type, body); } public abstract boolean isSuccessfull(); public abstract boolean isResultPresent(String resultsType); public abstract String getOfferId(); ... }
  • 23. 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); } }
  • 24. Layer 4 Test scripts Step definitions Rx-objects Xml Modifier
  • 25. 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 getNodeByXpath(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) {…} ... ... ...
  • 26. Benefits of this approach - very simple to understand, read and write tests (pure KISS principle) - has lower entrance level - friendly for automation engineers without experience in web services testing - can be good option when you have a lot of business objects and entities - was successfully implemented on real project and shows good results
  • 27. Can we use RxObject for testing REST services? In theory – yes. public class RxObject { private String type; private Something body; private String format; private String responseFormat; private String httpMethod; ... ... ... } But this will be more complicated. Also you can take Rest Assured or other rest-automating framework.