KEMBAR78
Smart acceptance GUI tests with Selenium | PPTX
Smart acceptance GUI
tests with Selenium
>Denys~Zaiats
Agenda
1. Introduction into ATDD (BDD + Specification by example) and Cucumber.
2. Simple usage of Cucumber with Selenium.
3. Reporting as an important part of acceptance tests.
4. Smart UI testing.
What the software testing is?
Testing is the process of
evaluating a system or its
component(s) with the intent to
find whether it satisfies the
specified requirements or not.
Criterias of good tests:
● Highly accurate
● Easy maintainable and readable
● Good results
Highly accurate tests
1. Using auto-generate strings with special
symbols
2. Always to have different values for
usernames and passwords
3. Test boundary and middle values. (e.g:
0..100: -1, 0, 1, 25, 63, 99, 100, 101 )
4. Represent real business / user flow in the
tests
1. Using simple hardcoded strings for
verification like “abcd” or “1234”
2. Using username: test123 and password:
test123
3. Skipping the testing of boundary values
4. Jumping between the steps using tricky
navigation
Easy maintainable and readable tests
Scenario: Verify that main logo is displayed
When user navigates to 'https://www.facey.top'
Then page is displayed correctly
And language of the page is 'en'
driver.get(“https://www.facey.top”);
driver.findElement(By.id(“someId”)).isDisplayed()
;
…
function test(){
...
some function for verification of the language on
the page
...
}
Good results
Loading...
Test set: runner.RunnerMathTest
-------------------------------------------------------------------------------
Tests run: 8, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 19.809 sec
<<< FAILURE!
And language of the page is 'fr'(Scenario: Verify that main logo is
displayed) Time elapsed: 0.002 sec <<< FAILURE!
java.lang.AssertionError:
Recognised language on the page is: en
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at
steps.StepsImplementation.languageOfThePageIsEn(StepsImplementatio
n.java:55)
at ✽.And language of the page is 'fr'(smoke_scenario.feature:10)
Scenario: Verify that main logo is displayed Time elapsed: 0.003 sec
<<< FAILURE!
java.lang.AssertionError:
Recognised language on the page is: en
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at
steps.StepsImplementation.languageOfThePageIsEn(StepsImplementatio
n.java:55)
at ✽.And language of the page is 'fr'(smoke_scenario.feature:10)
Definition
“ATDD (Acceptance test-driven development) is a development methodology based on
communication between the business customers, the developers, and the testers. ATDD
encompasses many of the same practices as Specification by Example, Behaviour Driven
Development (BDD), Example-Driven Development (EDD), and Story Test-Driven Development
(SDD). All these processes aid developers and testers in understanding the customer’s needs
prior to implementation and allow customers to be able to converse in their own domain
language. ATDD is closely related to Test-Driven Development (TDD). It differs by the emphasis
on developer-tester-business customer collaboration. ATDD encompasses acceptance testing,
but highlights writing acceptance tests before developers begin coding.”
(from Wikipedia)
Specification by example
Author: Gojko Adzic
BDD frameworks for Java
Cucumber
Concordion
JBehave
Spock (groovy)
Easyb (groovy)
Example of Feature file
Not very clear scenario:
When user click on button
Then everything works
Selenium + Cucumber: how to start?
What You need to know about Cucumber
1. Maven dependencies to Cucumber
2. Feature file under “src/test/resources/../features/../”
3. Cucumber test runner
4. Implemented steps
Step 1. Prepare Yourself. Tools
1. IntelliJ IDEA
2. JDK 1.8
3. Maven
4. Set environment variables for JAVA and Maven (for Windows)
5. Install plugins for IntelliJ “Cucumber for Java” if not installed
6. Ready to go!
www.itarray.net - Lesson 1
Step 2. Maven dependencies
1. What is pom.xml?
2. Required dependencies for Cucumber and Selenium
Cucumbers features
1. Tags (@Smoke)
2. Scenario outlines (Tables)
First Selenium scenario
...So, what is Automotion?
Possibility to run any of existing web / mobile drivers from one place
Useful utils for web and mobile automation:
Scrolling, swiping, tapping, waiting, end so on
Manipulating by Android settings during test run
Validation of the language on web / mobile page
Tools for performing REST API testing
Testing of responsive design
Responsive design
How to test next things like:
Existing services
- Image recognition (not very effective)
- High costs
- Not easy integration with existing test framework
- Dependendencies to other services
- Specific syntax
What we need?
- Easy integration into existing framework
- Working with Selenium tests
- Readable syntax
- Fast and accurate results
Automotion Responsive UI Validator
We can do:
- Define approximate or precise values for measuring of the sizes
- Offsets and margins
- Comparison with offsets of other elements
- Overlapping (if inside or outside of specific elements)
- Correct alignment
- Different units for measuring
ResponsiveUIValidator uiValidator = new ResponsiveUIValidator(driver);
boolean result = uiValidator.init()
.findElement({rootEelement}, "Name of element")
.sameOffsetLeftAs({element} "Panel 1")
.sameOffsetLeftAs({element} "Button 1")
.sameOffsetRightAs({element} "Button 2")
.sameOffsetRightAs({element}, "Button 3)
.withCssValue("border", "2px", "solid", "#FBDCDC")
.withCssValue("border-radius", "4px")
.withoutCssValue("color", "#FFFFFF")
.sameSizeAs({list_elements},)
.insideOf({element}, "Container")
.notOverlapWith({element}, "Other element")
.withTopElement({element}, 10, 15)
.changeMetricsUnitsTo(ResponsiveUIValidator.Units.PERCENT)
.widthBetween(50, 55)
.heightBetween(90, 95)
.drawMap()
.validate();
uiValidator.generateReport();
Which platforms are supported
Summarise
BDD
Specification by example
Cucumber + Selenium
Visual UI testing
Questions?
Please, ask me what is unclear for You
Slide #30
Slide #30

Smart acceptance GUI tests with Selenium

  • 1.
    Smart acceptance GUI testswith Selenium >Denys~Zaiats
  • 2.
    Agenda 1. Introduction intoATDD (BDD + Specification by example) and Cucumber. 2. Simple usage of Cucumber with Selenium. 3. Reporting as an important part of acceptance tests. 4. Smart UI testing.
  • 3.
    What the softwaretesting is? Testing is the process of evaluating a system or its component(s) with the intent to find whether it satisfies the specified requirements or not. Criterias of good tests: ● Highly accurate ● Easy maintainable and readable ● Good results
  • 4.
    Highly accurate tests 1.Using auto-generate strings with special symbols 2. Always to have different values for usernames and passwords 3. Test boundary and middle values. (e.g: 0..100: -1, 0, 1, 25, 63, 99, 100, 101 ) 4. Represent real business / user flow in the tests 1. Using simple hardcoded strings for verification like “abcd” or “1234” 2. Using username: test123 and password: test123 3. Skipping the testing of boundary values 4. Jumping between the steps using tricky navigation
  • 5.
    Easy maintainable andreadable tests Scenario: Verify that main logo is displayed When user navigates to 'https://www.facey.top' Then page is displayed correctly And language of the page is 'en' driver.get(“https://www.facey.top”); driver.findElement(By.id(“someId”)).isDisplayed() ; … function test(){ ... some function for verification of the language on the page ... }
  • 6.
    Good results Loading... Test set:runner.RunnerMathTest ------------------------------------------------------------------------------- Tests run: 8, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 19.809 sec <<< FAILURE! And language of the page is 'fr'(Scenario: Verify that main logo is displayed) Time elapsed: 0.002 sec <<< FAILURE! java.lang.AssertionError: Recognised language on the page is: en at org.junit.Assert.fail(Assert.java:88) at org.junit.Assert.assertTrue(Assert.java:41) at steps.StepsImplementation.languageOfThePageIsEn(StepsImplementatio n.java:55) at ✽.And language of the page is 'fr'(smoke_scenario.feature:10) Scenario: Verify that main logo is displayed Time elapsed: 0.003 sec <<< FAILURE! java.lang.AssertionError: Recognised language on the page is: en at org.junit.Assert.fail(Assert.java:88) at org.junit.Assert.assertTrue(Assert.java:41) at steps.StepsImplementation.languageOfThePageIsEn(StepsImplementatio n.java:55) at ✽.And language of the page is 'fr'(smoke_scenario.feature:10)
  • 7.
    Definition “ATDD (Acceptance test-drivendevelopment) is a development methodology based on communication between the business customers, the developers, and the testers. ATDD encompasses many of the same practices as Specification by Example, Behaviour Driven Development (BDD), Example-Driven Development (EDD), and Story Test-Driven Development (SDD). All these processes aid developers and testers in understanding the customer’s needs prior to implementation and allow customers to be able to converse in their own domain language. ATDD is closely related to Test-Driven Development (TDD). It differs by the emphasis on developer-tester-business customer collaboration. ATDD encompasses acceptance testing, but highlights writing acceptance tests before developers begin coding.” (from Wikipedia)
  • 9.
  • 10.
  • 11.
    BDD frameworks forJava Cucumber Concordion JBehave Spock (groovy) Easyb (groovy)
  • 12.
    Example of Featurefile Not very clear scenario: When user click on button Then everything works
  • 13.
    Selenium + Cucumber:how to start?
  • 14.
    What You needto know about Cucumber 1. Maven dependencies to Cucumber 2. Feature file under “src/test/resources/../features/../” 3. Cucumber test runner 4. Implemented steps
  • 15.
    Step 1. PrepareYourself. Tools 1. IntelliJ IDEA 2. JDK 1.8 3. Maven 4. Set environment variables for JAVA and Maven (for Windows) 5. Install plugins for IntelliJ “Cucumber for Java” if not installed 6. Ready to go! www.itarray.net - Lesson 1
  • 16.
    Step 2. Mavendependencies 1. What is pom.xml? 2. Required dependencies for Cucumber and Selenium
  • 18.
    Cucumbers features 1. Tags(@Smoke) 2. Scenario outlines (Tables)
  • 20.
    First Selenium scenario ...So,what is Automotion? Possibility to run any of existing web / mobile drivers from one place Useful utils for web and mobile automation: Scrolling, swiping, tapping, waiting, end so on Manipulating by Android settings during test run Validation of the language on web / mobile page Tools for performing REST API testing Testing of responsive design
  • 22.
    Responsive design How totest next things like:
  • 23.
    Existing services - Imagerecognition (not very effective) - High costs - Not easy integration with existing test framework - Dependendencies to other services - Specific syntax
  • 24.
    What we need? -Easy integration into existing framework - Working with Selenium tests - Readable syntax - Fast and accurate results
  • 25.
    Automotion Responsive UIValidator We can do: - Define approximate or precise values for measuring of the sizes - Offsets and margins - Comparison with offsets of other elements - Overlapping (if inside or outside of specific elements) - Correct alignment - Different units for measuring ResponsiveUIValidator uiValidator = new ResponsiveUIValidator(driver); boolean result = uiValidator.init() .findElement({rootEelement}, "Name of element") .sameOffsetLeftAs({element} "Panel 1") .sameOffsetLeftAs({element} "Button 1") .sameOffsetRightAs({element} "Button 2") .sameOffsetRightAs({element}, "Button 3) .withCssValue("border", "2px", "solid", "#FBDCDC") .withCssValue("border-radius", "4px") .withoutCssValue("color", "#FFFFFF") .sameSizeAs({list_elements},) .insideOf({element}, "Container") .notOverlapWith({element}, "Other element") .withTopElement({element}, 10, 15) .changeMetricsUnitsTo(ResponsiveUIValidator.Units.PERCENT) .widthBetween(50, 55) .heightBetween(90, 95) .drawMap() .validate(); uiValidator.generateReport();
  • 27.
  • 28.
  • 29.
    Questions? Please, ask mewhat is unclear for You
  • 30.

Editor's Notes

  • #3 Today I will show You some screenshots, charts, videos and live examples.
  • #4 Ask about is people agree with it. If not - ask why.
  • #7 Ask people if they like it and if they do the same reporting on the project
  • #8 Joke about many text.
  • #17 Pom file is the main Maven file that defines how we want to run maven goals, which dependencies to use.