SlideShare uma empresa Scribd logo
1 de 57
Baixar para ler offline
Easy:) Tests with Selenide and Easyb

Iakiv Kramarenko
Conventions :)
●

Sympathy colors***:
Green

=

Orange

Red

=

=

*** often are subjective and applied to specific context ;)
●

At project with no Web UI automation, no unit testing

●

With 4(5) Manual QA
–

●

Using checklists + long detailed End to End test cases

With 1 QA Automation found
Testing single page web app
●

Ajax

●

only <div>, <a>, <input>
–

Inconsistent implementation

●

No confident urls

●

One current Frame/Page with content per user step
–

Deep structure:
●

–

Authorization > Menus > SubMenus > Tabs > Extra > Extra

Modal dialogs
Met Requirements
●

Automate high level scenarios
–
–

●

use AC from stories
existed Manual Scenarios

Use 3rd party solutions
–

●

Java Desired

Involve Manual QA
–
–

●

provide easy to use solution
BDD Desired

In Tough Deadlines :)
Dreaming of framework...
●

Fast in development
–

Using instruments quite agile to adapt to project specifics

●

Extremely easy to use and learn

●

Simple DSL for tests

●

BDD – light and DRY as
much as possible
“Raw” Webdriver with tunings
(HtmlElements, Matchers, etc.)
●

No convenient and concise Ajax support out of the box

●

Code redundancy
–

Driver creation

–

Finding elements

–

Assert element states
●

Harmcrest Matchers are easy, but assertThat() knows nothing
about Ajax
–

HtmlElements gives powerful but bulky “waiting” decorators
(see links [1][2])
Concordion
●

Hard to extend
–

Custom commands (asserts)

<html xmlns:concordion="http://www.concordion.org/2007/concordion">
<body>
<p concordion:assertEquals="getGreeting()">Hello World!</p>
</body>
</html>
Thucydides
●

No convenient Ajax support
–

Asserts and Conditions are bound
●

●

Framework, not a Lib
–

Not agile
●

●

Hard to extend

It's hard to use some patterns (e.g. LoadableComponent)

Monstrous Manual :)
= Redundancy
Not BDD
Easy:) Instruments
@Test
public void userCanLoginByUsername() {
open("/login");
$(By.name("user.name")).setValue("johny");
$("#submit").click();
$(".loading_progress").should(disappear);
$("#username").shouldHave(text("Hello, Johny!"));
}
Selenide Pros
●

Wrapper over Selenium with Concise API

●

Lib, not a Framework
–

●

You still have your raw WebDriver when needed

should style asserts
–

Independent from Conditions

–

Waiting for conditions (Ajax friendly)

●

Screenshot reporting on each failed should

●

Screenshot API
–
–

●

Providing screenshots' context
Get all screenshots for context

Actively supported by authors
Killer Feature
Selenide Conditions
public static final Condition checked = new Condition("checked") {
@Override
public boolean apply(WebElement element) {
return isChecked(element);
}

@Override
public String actualValue(WebElement element) {
return isChecked(element) ? "checked" : "unchecked";
}

@Override
public String toString(){
return "checked";
}
};
Or even shorter
public static final Condition checked = new Condition("checked") {

@Override
public boolean apply(WebElement element) {

return isChecked(element);
}
};
Custom Condition Examples
Aliases
Implementation
public static final Condition checked =
Condition.hasClass("checked");

public static final Condition enabled =
Condition.hasNotClass("disabled");

public static final Condition expanded =
Condition.attribute("area-expanded", "true");
Usage
showPasswordCheckBox().shouldBe(not(checked));

applyButton().shouldBe(enabled);

treeItem.shouldBe(expanded);
Usage: is
public static void ensureExpanded(SelenideElement item){
if (item.is(not(expanded))){

}
}

expand(item);
Own implementation
Implementation (1)
public static final Condition inRadioMode(final String radioMode){
return new Condition("in radio mode: " + radioMode) {
@Override
public boolean apply(WebElement webElement) {
boolean res = true;
for(WebElement mode: Mode.modes(webElement)){
if (Mode.value(mode).equals(radioMode)){
res = res &&
mode.getAttribute("class").contains("active");

} else {
res = res && !
}

}

}
};

}
return res;

mode.getAttribute("class").contains("active");
Implementation (2)
public static final Condition faded = new Condition("faded
with backdrop" )
{
@Override
public boolean apply(WebElement element) {
return backDropFor(element).exists();
}
};
Implementation (3)
public static Condition leftSliderPosition(final Integer
position)
{
return new Condition("left slider position " + position)
{

@Override
public boolean apply(WebElement webElement) {
return

getLeftSliderCurrentPosition(webElement).equals(position);
}
};
}
Usage
tabContainer().shouldBe(faded);

accessRadioButtons().shouldBe(inRadioMode(PRIVATE));

scheduler.shouldHave(leftSliderPosition(100));
Composition*

* public static final will be omitted for simplicity
Implementation
Condition loadingDialog = condition(loadingDialog(), exist);
Condition applyButtonDisabled = condition(primeBtn(), disabled);
Condition cancelButtonDisabled = condition(scndBtn(), disabled);

Condition processed = with_(no(Modal.dialog()));
Condition loaded = and(processed, with_(no(loadingDialog)),
with_(applyButtonDisabled));
Condition savedForSure = and(loaded, with_(saveSuccessMsg()));
Condition failedToSave = and(
processed,
with_(no(loadingDialog)),
with_(not(applyButtonDisabled)),
with_(no(saveSuccessMsg())),
with_(not(cancelButtonDisabled)),
with_(saveErrorsMsg()));
Usage
//fill page with valid/invalid data...

Page.save()
Page.shouldBe(and(
failedToSave,
with(usernameValidation(), currentPassValidation()),
with(no(newPassValidation(), matchPassValidation()))))

//fix errors and save...

Page.shouldBe(savedForSure)
Selenide Cons
●

Young:)
–

Many things can be improved
●

Error messages

●

Condition helpers

●

Screenshot API

–
–

●

Tones of them have been resolved so far
Others can be implemented as your own extensions

Not all-powerfull
–

For some things you will still need raw WebDriver
Easyb Pros
●

Gherkin (given/when/then) and its implementation live at
the same file
–

better maintainability

–

more DRY code

●

no implementation => “pending” test

●

simple but nice looking reports

●

groovy as a script language for tests
–

scenarios are ordered
Easyb Cons
●

bad support of framework from authors.

●

some features are broken
–

●

no tags per scenario/step
–

●
●

●

before_each
only tags per story

Stack trace of error messages is clipped
No out of the box way to put listeners on
steps/scenarios
“Shared steps” feature is present but not quite
handy
Easyb Selenide Integration
Problem
Selenide shoulds vs Easyb shoulds
Easyb catches any 'should' (shouldBe, shouldHave, ...)
except “should” and “shouldNot”

showPasswordCheckBox().shouldNot(checked);
//Less readable:(
Solution => Decorators
showPasswordCheckBox().shouldNot(be(checked));
showPasswordCheckBox().should(be(not(checked)));
All Together :)
Preconditions to BDD
Team is competent :)

●

●

PO knows what is
Criteria of Good Requirement
Manual QA knows how to write
“Automatable” Scenarios
Pending Easyb Story by PO
description "Products List page"
scenario "Add new product", {
given "On Products List page"
then "new product can be added"
}
Pending Detailed Easyb Story by
Manual QA
description "Products List page"
scenario "Add new product", {
given "On Products List page"
and "No custom product with 'Product_1' name exist"
then "new product with 'Product_1' name can be added"
and "after relogin still present"
}
Implemented Easyb Story
description "ProductsList test"
tags "functional"
BaseTest.setup()
scenario "Add new product", {
given "On ProductsList page",{
ProductsList.page().get()
}
and "No custom product with '" + TEST_PRODUCT + "' name exist", {
Table.ensureHasNo(cellByText(TEST_PRODUCT))
}
then "new product with '" + TEST_PRODUCT + "' name can be added", {
ProductsList.addProductForSure(TEST_PRODUCT)
}
and "after relogin still present", {
cleanReLogin()
Table.cellByText(TEST_PRODUCT).should(be(visible));
}
}
Easyb Report
Failed
Easyb
Report
Alternative: TestNG test
public class ProductManagement extends AbstractTest {
@Test
public void testNewProductCanBeAdded() {
ProductsList.page().get();
Table.ensureHasNo(cellByText(TEST_PRODUCT));
ProductsList.addProductForSure(TEST_PRODUCT);
cleanReLogin();
Table.cellByText(TEST_PRODUCT).should(Be.visible);
}
}
Alternative: TestNG Report
Failed TestNG Report
When Easyb ?
●

“Somebody” wants Gherkin
–

Automation resources are
limited, and help may come from
PO or Manual QA providing
detailed 'steps to code'

●

Detailed reporting of test steps

●

Ordered tests execution (as present in the file)
When TestNG/Junit ?
●

When you have strong 'agile' devs/automation which know why
what and how to test and do write tests.
–

Hence you never need pretty looking reports to please your
manager customer because you just have high quality product.
Ideas for improvements
●

Kill Kenny
–

if he is the only who wants Gherkin:)

–

and stay KISS with TestNG/Junit

●

Contribute to Easyb:)

●

Bless Selenide:)
–

Authors will contribute nevertheless
Q&A
Resources, Links
●

●

●

Src of example test framework:
https://github.com/yashaka/gribletest
Application under test used in easyb examples:
http://grible.org/download.php
Instruments
–

http://selenide.org/

–

http://easyb.org/
●

To Artem Chernysh for implementation of main base part
of the test framework for this presentation
–

●

To Maksym Barvinskyi for application under test
–

●

https://github.com/elaides/gribletest
http://grible.org/

To Andrei Solntsev, creator of Selenide, for close
collaboration on Selenide Q&A, and new features
implemented:)
Contacts
●

yashaka@gmail.com

●

skype: yashaolin

●

http://www.linkedin.com/in/iakivkramarenko

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
selenium with python training
selenium with python trainingselenium with python training
selenium with python training
 
Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson
 
Testing in-python-and-pytest-framework
Testing in-python-and-pytest-frameworkTesting in-python-and-pytest-framework
Testing in-python-and-pytest-framework
 
Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
 
Grails Simple Login
Grails Simple LoginGrails Simple Login
Grails Simple Login
 
Full Stack Flutter Testing
Full Stack Flutter Testing Full Stack Flutter Testing
Full Stack Flutter Testing
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with Mockito
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Angular Advanced Routing
Angular Advanced RoutingAngular Advanced Routing
Angular Advanced Routing
 
Flutter, prazer
Flutter, prazerFlutter, prazer
Flutter, prazer
 
Javascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big PictureJavascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big Picture
 
A journey beyond the page object pattern
A journey beyond the page object patternA journey beyond the page object pattern
A journey beyond the page object pattern
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytest
 
Vue Vuex 101
Vue Vuex 101Vue Vuex 101
Vue Vuex 101
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 

Semelhante a Easy tests with Selenide and Easyb

Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Iakiv Kramarenko
 
Test strategy for web development
Test strategy for web developmentTest strategy for web development
Test strategy for web developmentalice yang
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance testBryan Liu
 
Workshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsWorkshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsSami Ekblad
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testingdrewz lin
 
Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018Ortus Solutions, Corp
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Mahmoud Hamed Mahmoud
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instrumentsArtem Nagornyi
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAlan Richardson
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webpjcozzi
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan Eugen Stan
 
Hybrid App using WordPress
Hybrid App using WordPressHybrid App using WordPress
Hybrid App using WordPressHaim Michael
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptdavejohnson
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF SummitOrtus Solutions, Corp
 
Component Based Unit Testing ADF with Selenium
Component Based Unit Testing ADF with SeleniumComponent Based Unit Testing ADF with Selenium
Component Based Unit Testing ADF with SeleniumRichard Olrichs
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with seleniumTzirla Rozental
 

Semelhante a Easy tests with Selenide and Easyb (20)

Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
 
Test strategy for web development
Test strategy for web developmentTest strategy for web development
Test strategy for web development
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance test
 
Workshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsWorkshop: Building Vaadin add-ons
Workshop: Building Vaadin add-ons
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018Testing for fun in production Into The Box 2018
Testing for fun in production Into The Box 2018
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and Beyond
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
WebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open webWebGL: GPU acceleration for the open web
WebGL: GPU acceleration for the open web
 
Jasmine with JS-Test-Driver
Jasmine with JS-Test-DriverJasmine with JS-Test-Driver
Jasmine with JS-Test-Driver
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
Hybrid App using WordPress
Hybrid App using WordPressHybrid App using WordPress
Hybrid App using WordPress
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Web ui testing
Web ui testingWeb ui testing
Web ui testing
 
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
3 Ways to test your ColdFusion API - 2017 Adobe CF Summit
 
Component Based Unit Testing ADF with Selenium
Component Based Unit Testing ADF with SeleniumComponent Based Unit Testing ADF with Selenium
Component Based Unit Testing ADF with Selenium
 
Automated Testing ADF with Selenium
Automated Testing ADF with SeleniumAutomated Testing ADF with Selenium
Automated Testing ADF with Selenium
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 

Mais de Iakiv Kramarenko

Отзывы на раннюю версию курса «Искусство Автоматизации с Java + Selenide»
Отзывы на раннюю версию курса «Искусство Автоматизации с Java + Selenide» Отзывы на раннюю версию курса «Искусство Автоматизации с Java + Selenide»
Отзывы на раннюю версию курса «Искусство Автоматизации с Java + Selenide» Iakiv Kramarenko
 
Dont be fooled with BDD, automation engineer! ;)
Dont be fooled with BDD, automation engineer! ;)Dont be fooled with BDD, automation engineer! ;)
Dont be fooled with BDD, automation engineer! ;)Iakiv Kramarenko
 
Web ui tests examples with selenide, nselene, selene & capybara
Web ui tests examples with  selenide, nselene, selene & capybaraWeb ui tests examples with  selenide, nselene, selene & capybara
Web ui tests examples with selenide, nselene, selene & capybaraIakiv Kramarenko
 
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...Iakiv Kramarenko
 
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]Iakiv Kramarenko
 
You do not need automation engineer - Sqa Days - 2015 - EN
You do not need automation engineer  - Sqa Days - 2015 - ENYou do not need automation engineer  - Sqa Days - 2015 - EN
You do not need automation engineer - Sqa Days - 2015 - ENIakiv Kramarenko
 
Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015Iakiv Kramarenko
 
Write Selenide in Python 15 min
Write Selenide in Python 15 minWrite Selenide in Python 15 min
Write Selenide in Python 15 minIakiv Kramarenko
 
Automation is Easy! (python version)
Automation is Easy! (python version)Automation is Easy! (python version)
Automation is Easy! (python version)Iakiv Kramarenko
 

Mais de Iakiv Kramarenko (11)

Отзывы на раннюю версию курса «Искусство Автоматизации с Java + Selenide»
Отзывы на раннюю версию курса «Искусство Автоматизации с Java + Selenide» Отзывы на раннюю версию курса «Искусство Автоматизации с Java + Selenide»
Отзывы на раннюю версию курса «Искусство Автоматизации с Java + Selenide»
 
Dont be fooled with BDD, automation engineer! ;)
Dont be fooled with BDD, automation engineer! ;)Dont be fooled with BDD, automation engineer! ;)
Dont be fooled with BDD, automation engineer! ;)
 
Easy automation.py
Easy automation.pyEasy automation.py
Easy automation.py
 
KISS Automation.py
KISS Automation.pyKISS Automation.py
KISS Automation.py
 
Web ui tests examples with selenide, nselene, selene & capybara
Web ui tests examples with  selenide, nselene, selene & capybaraWeb ui tests examples with  selenide, nselene, selene & capybara
Web ui tests examples with selenide, nselene, selene & capybara
 
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
 
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
Selenide alternative in Python - Introducing Selene [SeleniumCamp 2016]
 
You do not need automation engineer - Sqa Days - 2015 - EN
You do not need automation engineer  - Sqa Days - 2015 - ENYou do not need automation engineer  - Sqa Days - 2015 - EN
You do not need automation engineer - Sqa Days - 2015 - EN
 
Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015Polyglot automation - QA Fest - 2015
Polyglot automation - QA Fest - 2015
 
Write Selenide in Python 15 min
Write Selenide in Python 15 minWrite Selenide in Python 15 min
Write Selenide in Python 15 min
 
Automation is Easy! (python version)
Automation is Easy! (python version)Automation is Easy! (python version)
Automation is Easy! (python version)
 

Último

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 

Último (20)

Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 

Easy tests with Selenide and Easyb

  • 1. Easy:) Tests with Selenide and Easyb Iakiv Kramarenko
  • 2. Conventions :) ● Sympathy colors***: Green = Orange Red = = *** often are subjective and applied to specific context ;)
  • 3. ● At project with no Web UI automation, no unit testing ● With 4(5) Manual QA – ● Using checklists + long detailed End to End test cases With 1 QA Automation found
  • 4. Testing single page web app ● Ajax ● only <div>, <a>, <input> – Inconsistent implementation ● No confident urls ● One current Frame/Page with content per user step – Deep structure: ● – Authorization > Menus > SubMenus > Tabs > Extra > Extra Modal dialogs
  • 5. Met Requirements ● Automate high level scenarios – – ● use AC from stories existed Manual Scenarios Use 3rd party solutions – ● Java Desired Involve Manual QA – – ● provide easy to use solution BDD Desired In Tough Deadlines :)
  • 6. Dreaming of framework... ● Fast in development – Using instruments quite agile to adapt to project specifics ● Extremely easy to use and learn ● Simple DSL for tests ● BDD – light and DRY as much as possible
  • 7.
  • 8. “Raw” Webdriver with tunings (HtmlElements, Matchers, etc.) ● No convenient and concise Ajax support out of the box ● Code redundancy – Driver creation – Finding elements – Assert element states ● Harmcrest Matchers are easy, but assertThat() knows nothing about Ajax – HtmlElements gives powerful but bulky “waiting” decorators (see links [1][2])
  • 9. Concordion ● Hard to extend – Custom commands (asserts) <html xmlns:concordion="http://www.concordion.org/2007/concordion"> <body> <p concordion:assertEquals="getGreeting()">Hello World!</p> </body> </html>
  • 10. Thucydides ● No convenient Ajax support – Asserts and Conditions are bound ● ● Framework, not a Lib – Not agile ● ● Hard to extend It's hard to use some patterns (e.g. LoadableComponent) Monstrous Manual :)
  • 14.
  • 15. @Test public void userCanLoginByUsername() { open("/login"); $(By.name("user.name")).setValue("johny"); $("#submit").click(); $(".loading_progress").should(disappear); $("#username").shouldHave(text("Hello, Johny!")); }
  • 16. Selenide Pros ● Wrapper over Selenium with Concise API ● Lib, not a Framework – ● You still have your raw WebDriver when needed should style asserts – Independent from Conditions – Waiting for conditions (Ajax friendly) ● Screenshot reporting on each failed should ● Screenshot API – – ● Providing screenshots' context Get all screenshots for context Actively supported by authors
  • 18. public static final Condition checked = new Condition("checked") { @Override public boolean apply(WebElement element) { return isChecked(element); } @Override public String actualValue(WebElement element) { return isChecked(element) ? "checked" : "unchecked"; } @Override public String toString(){ return "checked"; } };
  • 19. Or even shorter public static final Condition checked = new Condition("checked") { @Override public boolean apply(WebElement element) { return isChecked(element); } };
  • 22. Implementation public static final Condition checked = Condition.hasClass("checked"); public static final Condition enabled = Condition.hasNotClass("disabled"); public static final Condition expanded = Condition.attribute("area-expanded", "true");
  • 24. Usage: is public static void ensureExpanded(SelenideElement item){ if (item.is(not(expanded))){ } } expand(item);
  • 26. Implementation (1) public static final Condition inRadioMode(final String radioMode){ return new Condition("in radio mode: " + radioMode) { @Override public boolean apply(WebElement webElement) { boolean res = true; for(WebElement mode: Mode.modes(webElement)){ if (Mode.value(mode).equals(radioMode)){ res = res && mode.getAttribute("class").contains("active"); } else { res = res && ! } } } }; } return res; mode.getAttribute("class").contains("active");
  • 27. Implementation (2) public static final Condition faded = new Condition("faded with backdrop" ) { @Override public boolean apply(WebElement element) { return backDropFor(element).exists(); } };
  • 28. Implementation (3) public static Condition leftSliderPosition(final Integer position) { return new Condition("left slider position " + position) { @Override public boolean apply(WebElement webElement) { return getLeftSliderCurrentPosition(webElement).equals(position); } }; }
  • 30. Composition* * public static final will be omitted for simplicity
  • 31. Implementation Condition loadingDialog = condition(loadingDialog(), exist); Condition applyButtonDisabled = condition(primeBtn(), disabled); Condition cancelButtonDisabled = condition(scndBtn(), disabled); Condition processed = with_(no(Modal.dialog())); Condition loaded = and(processed, with_(no(loadingDialog)), with_(applyButtonDisabled)); Condition savedForSure = and(loaded, with_(saveSuccessMsg())); Condition failedToSave = and( processed, with_(no(loadingDialog)), with_(not(applyButtonDisabled)), with_(no(saveSuccessMsg())), with_(not(cancelButtonDisabled)), with_(saveErrorsMsg()));
  • 32. Usage //fill page with valid/invalid data... Page.save() Page.shouldBe(and( failedToSave, with(usernameValidation(), currentPassValidation()), with(no(newPassValidation(), matchPassValidation())))) //fix errors and save... Page.shouldBe(savedForSure)
  • 33. Selenide Cons ● Young:) – Many things can be improved ● Error messages ● Condition helpers ● Screenshot API – – ● Tones of them have been resolved so far Others can be implemented as your own extensions Not all-powerfull – For some things you will still need raw WebDriver
  • 34.
  • 35. Easyb Pros ● Gherkin (given/when/then) and its implementation live at the same file – better maintainability – more DRY code ● no implementation => “pending” test ● simple but nice looking reports ● groovy as a script language for tests – scenarios are ordered
  • 36. Easyb Cons ● bad support of framework from authors. ● some features are broken – ● no tags per scenario/step – ● ● ● before_each only tags per story Stack trace of error messages is clipped No out of the box way to put listeners on steps/scenarios “Shared steps” feature is present but not quite handy
  • 38. Problem Selenide shoulds vs Easyb shoulds Easyb catches any 'should' (shouldBe, shouldHave, ...) except “should” and “shouldNot” showPasswordCheckBox().shouldNot(checked); //Less readable:(
  • 41. Preconditions to BDD Team is competent :) ● ● PO knows what is Criteria of Good Requirement Manual QA knows how to write “Automatable” Scenarios
  • 42. Pending Easyb Story by PO description "Products List page" scenario "Add new product", { given "On Products List page" then "new product can be added" }
  • 43. Pending Detailed Easyb Story by Manual QA description "Products List page" scenario "Add new product", { given "On Products List page" and "No custom product with 'Product_1' name exist" then "new product with 'Product_1' name can be added" and "after relogin still present" }
  • 44. Implemented Easyb Story description "ProductsList test" tags "functional" BaseTest.setup() scenario "Add new product", { given "On ProductsList page",{ ProductsList.page().get() } and "No custom product with '" + TEST_PRODUCT + "' name exist", { Table.ensureHasNo(cellByText(TEST_PRODUCT)) } then "new product with '" + TEST_PRODUCT + "' name can be added", { ProductsList.addProductForSure(TEST_PRODUCT) } and "after relogin still present", { cleanReLogin() Table.cellByText(TEST_PRODUCT).should(be(visible)); } }
  • 47. Alternative: TestNG test public class ProductManagement extends AbstractTest { @Test public void testNewProductCanBeAdded() { ProductsList.page().get(); Table.ensureHasNo(cellByText(TEST_PRODUCT)); ProductsList.addProductForSure(TEST_PRODUCT); cleanReLogin(); Table.cellByText(TEST_PRODUCT).should(Be.visible); } }
  • 50. When Easyb ? ● “Somebody” wants Gherkin – Automation resources are limited, and help may come from PO or Manual QA providing detailed 'steps to code' ● Detailed reporting of test steps ● Ordered tests execution (as present in the file)
  • 51. When TestNG/Junit ? ● When you have strong 'agile' devs/automation which know why what and how to test and do write tests. – Hence you never need pretty looking reports to please your manager customer because you just have high quality product.
  • 52. Ideas for improvements ● Kill Kenny – if he is the only who wants Gherkin:) – and stay KISS with TestNG/Junit ● Contribute to Easyb:) ● Bless Selenide:) – Authors will contribute nevertheless
  • 53.
  • 54. Q&A
  • 55. Resources, Links ● ● ● Src of example test framework: https://github.com/yashaka/gribletest Application under test used in easyb examples: http://grible.org/download.php Instruments – http://selenide.org/ – http://easyb.org/
  • 56. ● To Artem Chernysh for implementation of main base part of the test framework for this presentation – ● To Maksym Barvinskyi for application under test – ● https://github.com/elaides/gribletest http://grible.org/ To Andrei Solntsev, creator of Selenide, for close collaboration on Selenide Q&A, and new features implemented:)