Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Selenide
Volodymyr Zdvizhkov
Senior Automation Engineer
3
• Selenium IDE - a Chrome and Firefox add-on that will do
simple record-and-playback of interactions with the
browser. Scripts are recorded in the Selenium-specific
scripting language Selenese
• Selenium-Grid allows you run your tests on different remote
machines against different browsers in parallel. Selenium
Grid is a server that allows tests to use web browser
instances running on remote machines
• Selenium WebDriver - a collection of language specific
bindings to drive a browser- the way it is meant to be driven
4
• Selenide is a framework for writing easy-to-read and easy-
to-maintain automated tests in Java. It defines concise tests
at the same time against different browsers and operating
systems
• Selenoid is a powerful Go implementation of original Selenium hub code
5
• Most common UI automation issues
• Motivation to create new framework
• Selenide features
• Web application to be tested
• Test cases to be covered
• Framework structure
• Pom xml dependencies
• Setting up framework from scratch
Not stable. Flaky tests
6
Reasons of 90%* flaky tests:
• Ajax requests: speed
• Ajax requests: ordering
• JS speed
*= "https://www.youtube.com/watch?v=jLG3RXECQU8”
Need of permanent maintenance
7
• NoSuchElementException - unable to locate element
{"method":"xpath","selector“: “someSelector”}
• StaleElementException - generally this is due to the
DOM being updated and you trying to access an
updated/new element - but the DOM's refreshed so
it's an invalid reference you have.
Automation framework architecture complexity
8
Why always me?
Bad descriptions are easy to write
9
Message: Expected: True But was: False
• Home page should be opened.
• Home page should be opened. Current url: https:://url
• Home page is not visible.
• Home page is not displayed. But should be
• User is not redirected to Home page
10
The most common tool for UI tests in
Java today is Selenium WebDriver.
Selenium WebDriver is a great tool, but
it’s not a tool for testing. It’s a tool for
browser manipulation.
11
Serenity helps you to write cleaner and more maintainable
automated acceptance and regression tests faster. Serenity
also uses the test results to produce illustrated, narrative
reports that document and describe what your application
does and how it works.
12
Cucumber is a software tool used by computer
programmers for testing other software. It runs
automated acceptance tests written in a behavior-
driven development (BDD) style.
13
Galen Framework might be a perfect fit for your
needs if your automation efforts are focused on
user experience design (UX) or layout testing for
responsive websites.
14
How about Selenide?
15
Selenide is a tool for writing concise, expressive and stable UI tests in Java.
16
• Free, open-source
• Makes your tests shorter and more readable
• Ajax support, smart waiting
• Simple configuration
• Automated screenshots
• Pre-setup browser (transparent webDriver)
• Soft assertions
17
The most annoying problem of UI Tests is timeouts
driver.manage().timeouts().implicityWait(10, TimeUnit.SECONDS);
actions
checks
WebDriverWait wait = new WebDriverWait(driver, 10000);
wait.until(ExpectedConditions.presenceOfElementLocated
(By.id("id“));
waitUntil(appear, 20000)
Configuration.timeout = 10000;
Our goal is to emulate user
18
• byText() – find element with given text (the whole text, not substring)
• withText() – find element containing given text (as substring)
Poor software doesn't have documentation. Brilliant software doesn't need documentation
19
Do Action Check
Keep it simple
Transparent WebDriver
20
You don’t need to set up WebDriver logic directly. Selenide will
start and shut down the browser automatically whenever it’s
needed.
Just use:
• open(string url) - The main starting point in your tests.
Open a browser window with given URL
• close() - Close the browser if it's open
Most popular browsers supported: Chrome, Firefox, Ie, Safari,
Opera, etc.
Run browser command: -Dselenide.browser=browserName.
Concise fluent API for tests
21
• shouldHave(textCaseSensitive(String substring));
• dragAndDropTo(String selector);
• sizeLessThanOrEqual(); sizeNotEqual(); sizeGreaterThan();
• atBottom();
• executeJavaScript(String jsCode, Object… arguments);
• doubleClick();
• shouldHave(exactTextCaseSensitive(String text));
• pressEnter(); pressEscape(); pressTab();
Concise fluent API for tests
22
• matchesText() - assert that given element's text matches given regular expression
• empty() - for input element/other element, check that value is missing or empty
• present(); exist(); – returns true if element is present in DOM, otherwise – false
• hidden(); disappear(); not(visible) - checks that element is not visible / not exists
• be(), have() – are used to form human-readable condition
• download(); uploadFile();
• isImage() - returns true if the image is properly loaded
• getSelectedRadio() - returns selected element in radio group
Selenide takes screenshots automatically on every test failure
23
Configure by system property: -Dselenide.screenshots = true;
or programmatically:
above class: @Listeners({ScreenShooter.class}),
inside method/constructor: ScreenShooter.captureSuccessfulTests = true;
By default Selenide puts screenshots to folder: build/reports/tests.
Change directory: Dselenide.reportsFolder = test-result/reports
Additionally, you can take screenshot at any moment with a single
line of code: Screenshot(“my_file_name);
24
Selenide provides point to perform built in verification softly -
this means that Selenide will skip failed verification and collect
all of it and throw error only at the end of test. Available for
TestNG, JUnit4 and Junit5.
All the checks like: $.shouldHave(text("xxx")) will collect
errors and report all them at once. It could be useful if cost of
running tests is too big for you.
Above class: @Listeners({ SoftAsserts.class})
Inside test: Configuration.assertionMode = SOFT;
25
26
Write automation tests for:
27
28
Page objects
Tests
Test steps
Initialize Selenide elements
29
Initialize by elements Return Selenide element in method
30
31

More Related Content

Selenide

  • 3. 3 • Selenium IDE - a Chrome and Firefox add-on that will do simple record-and-playback of interactions with the browser. Scripts are recorded in the Selenium-specific scripting language Selenese • Selenium-Grid allows you run your tests on different remote machines against different browsers in parallel. Selenium Grid is a server that allows tests to use web browser instances running on remote machines • Selenium WebDriver - a collection of language specific bindings to drive a browser- the way it is meant to be driven
  • 4. 4 • Selenide is a framework for writing easy-to-read and easy- to-maintain automated tests in Java. It defines concise tests at the same time against different browsers and operating systems • Selenoid is a powerful Go implementation of original Selenium hub code
  • 5. 5 • Most common UI automation issues • Motivation to create new framework • Selenide features • Web application to be tested • Test cases to be covered • Framework structure • Pom xml dependencies • Setting up framework from scratch
  • 6. Not stable. Flaky tests 6 Reasons of 90%* flaky tests: • Ajax requests: speed • Ajax requests: ordering • JS speed *= "https://www.youtube.com/watch?v=jLG3RXECQU8”
  • 7. Need of permanent maintenance 7 • NoSuchElementException - unable to locate element {"method":"xpath","selector“: “someSelector”} • StaleElementException - generally this is due to the DOM being updated and you trying to access an updated/new element - but the DOM's refreshed so it's an invalid reference you have.
  • 8. Automation framework architecture complexity 8 Why always me?
  • 9. Bad descriptions are easy to write 9 Message: Expected: True But was: False • Home page should be opened. • Home page should be opened. Current url: https:://url • Home page is not visible. • Home page is not displayed. But should be • User is not redirected to Home page
  • 10. 10 The most common tool for UI tests in Java today is Selenium WebDriver. Selenium WebDriver is a great tool, but it’s not a tool for testing. It’s a tool for browser manipulation.
  • 11. 11 Serenity helps you to write cleaner and more maintainable automated acceptance and regression tests faster. Serenity also uses the test results to produce illustrated, narrative reports that document and describe what your application does and how it works.
  • 12. 12 Cucumber is a software tool used by computer programmers for testing other software. It runs automated acceptance tests written in a behavior- driven development (BDD) style.
  • 13. 13 Galen Framework might be a perfect fit for your needs if your automation efforts are focused on user experience design (UX) or layout testing for responsive websites.
  • 15. 15 Selenide is a tool for writing concise, expressive and stable UI tests in Java.
  • 16. 16 • Free, open-source • Makes your tests shorter and more readable • Ajax support, smart waiting • Simple configuration • Automated screenshots • Pre-setup browser (transparent webDriver) • Soft assertions
  • 17. 17 The most annoying problem of UI Tests is timeouts driver.manage().timeouts().implicityWait(10, TimeUnit.SECONDS); actions checks WebDriverWait wait = new WebDriverWait(driver, 10000); wait.until(ExpectedConditions.presenceOfElementLocated (By.id("id“)); waitUntil(appear, 20000) Configuration.timeout = 10000;
  • 18. Our goal is to emulate user 18 • byText() – find element with given text (the whole text, not substring) • withText() – find element containing given text (as substring)
  • 19. Poor software doesn't have documentation. Brilliant software doesn't need documentation 19 Do Action Check Keep it simple
  • 20. Transparent WebDriver 20 You don’t need to set up WebDriver logic directly. Selenide will start and shut down the browser automatically whenever it’s needed. Just use: • open(string url) - The main starting point in your tests. Open a browser window with given URL • close() - Close the browser if it's open Most popular browsers supported: Chrome, Firefox, Ie, Safari, Opera, etc. Run browser command: -Dselenide.browser=browserName.
  • 21. Concise fluent API for tests 21 • shouldHave(textCaseSensitive(String substring)); • dragAndDropTo(String selector); • sizeLessThanOrEqual(); sizeNotEqual(); sizeGreaterThan(); • atBottom(); • executeJavaScript(String jsCode, Object… arguments); • doubleClick(); • shouldHave(exactTextCaseSensitive(String text)); • pressEnter(); pressEscape(); pressTab();
  • 22. Concise fluent API for tests 22 • matchesText() - assert that given element's text matches given regular expression • empty() - for input element/other element, check that value is missing or empty • present(); exist(); – returns true if element is present in DOM, otherwise – false • hidden(); disappear(); not(visible) - checks that element is not visible / not exists • be(), have() – are used to form human-readable condition • download(); uploadFile(); • isImage() - returns true if the image is properly loaded • getSelectedRadio() - returns selected element in radio group
  • 23. Selenide takes screenshots automatically on every test failure 23 Configure by system property: -Dselenide.screenshots = true; or programmatically: above class: @Listeners({ScreenShooter.class}), inside method/constructor: ScreenShooter.captureSuccessfulTests = true; By default Selenide puts screenshots to folder: build/reports/tests. Change directory: Dselenide.reportsFolder = test-result/reports Additionally, you can take screenshot at any moment with a single line of code: Screenshot(“my_file_name);
  • 24. 24 Selenide provides point to perform built in verification softly - this means that Selenide will skip failed verification and collect all of it and throw error only at the end of test. Available for TestNG, JUnit4 and Junit5. All the checks like: $.shouldHave(text("xxx")) will collect errors and report all them at once. It could be useful if cost of running tests is too big for you. Above class: @Listeners({ SoftAsserts.class}) Inside test: Configuration.assertionMode = SOFT;
  • 25. 25
  • 26. 26
  • 30. Initialize by elements Return Selenide element in method 30
  • 31. 31