Escape from
the automation hell
How WebDriver works?
Unreadable Selenium tests
DSL
A domain-specific language (DSL) is a computer
language specialized to a particular application domain.
@Test
public void bookShouldBeSearchedByName() {
loginToBookStoreAs(regularUser);
openBookStorePage();
enterSearchCriteria("99 Francs");
searchBooks();
assertFalse(isEmptySearchResult());
}
Benefits of DSL Approach
● High-level - tests are in the language of product
management, at the user level
● Readable - product management can understand them
● Writable - easy for developer or QA to write new test
● Extensible - tests base is able to grow with DSL
Tips and Tricks of DSL Approach
● Use test class hierarchy or test helpers
● Use builders, visitors and other design patterns
● Reuse domain model from application
● Some common methods move to base test class
● Minimize usage of driver instance in tests
What is really Test Automation Framework?
Test Automation Framework (TAF) — the environment required for test
automation including test harnesses and artifacts such as test libraries.
Test Automation Solution (TAS) — the realization / implementation of a TAA
including test harnesses and artifacts such as test libraries.
Test Automation Architecture (TAA) — an instantiation of gTAA to define the
architecture of a TAS.
Generic Test Automation Architecture (gTAA) — providing a blueprint for test
automation solutions.
What is really Test Automation Framework?
What is Test Automation Engineer?
Test Automation Engineer (TAE) — the person who is
responsible for the design of a Test Automation Architecture
(TAA), including the implementation of the resulting Test
Automation Solution (TAS), its maintenance and technical
evolution.
TAE == Software Developer in Test
What is really WebDriver?
Selenium is
a suite of tools to automate web browsers
across many platforms.
What is really WebDriver?
Selenium automates browsers. That's it!
UI Test Automation Framework
Selenium inside
http://selenide.org
https://github.com/codeborne/selenide
Selenide > Main Goals
KISS principle in action
No unnecessary code → No unnecessary maintenance
Less to learn → Easier to use
Selenide > Keynote
Create a browser
Selenium WebDriver:
DesiredCapabilities desiredCapabilities = DesiredCapabilities.htmlUnit();
desiredCapabilities.setCapability(HtmlUnitDriver.INVALIDSELECTIONERROR, true);
desiredCapabilities.setCapability(HtmlUnitDriver.INVALIDXPATHERROR, false);
desiredCapabilities.setJavascriptEnabled(true);
WebDriver driver = new HtmlUnitDriver(desiredCapabilities);
Selenide:
open("https://catalog.onliner.by");
Selenide > Keynote
Shutdown a browser
Selenium WebDriver:
if (driver != null) {
driver.close();
}
Selenide:
// Do not care! Selenide closes the browser automatically
With Selenide You don't need to operate with Selenium WebDriver directly.
WebDriver will be automatically created/deleted during test start/finished.
Selenide > Keynote
Find element by id
Selenium WebDriver:
WebElement customer = driver.findElement(By.id("customerContainer"));
Selenide:
WebElement customer = $("#customerContainer");
or a longer conservative option:
WebElement customer = $(By.id("customerContainer"));
Selenide > Keynote
Assert that element has a correct text
Selenium WebDriver:
assertEquals("Customer profile",
driver.findElement(By.id("customerContainer")).getText());
Selenide:
$("#customerContainer").shouldHave(text("Customer profile"));
Selenide > Keynote
Ajax support (waiting for some event to happen)
Selenium WebDriver:
FluentWait<By> fluentWait = new FluentWait<By>(By.tagName("TEXTAREA"));
fluentWait.pollingEvery(100, TimeUnit.MILLISECONDS);
fluentWait.withTimeout(1000, TimeUnit.MILLISECONDS);
fluentWait.until(new Predicate<By>() {
public boolean apply(By by) {
try {
return browser.findElement(by).isDisplayed();
} catch (NoSuchElementException ex) {
return false;
}
}
});
assertEquals("John", browser.findElement(By.tagName("TEXTAREA")).getAttribute("value"));
Selenide:
$("TEXTAREA").shouldHave(value("John"));
This command automatically waits until element gets visible AND gets expected value.
Default timeout is 4 seconds and it's configurable.
Selenide > Keynote
Assert that element does not exist
Selenium WebDriver:
try {
WebElement element = driver.findElement(By.id("customerContainer"));
fail("Element should not exist: " + element);
}
catch (WebDriverException itsOk) {}
Selenide:
$("#customerContainer").shouldNot(exist);
Selenide > Keynote
Looking for element inside parent element
Selenium WebDriver:
WebElement parent = driver.findElement(By.id("customerContainer"));
WebElement element = parent.findElement(By.className("user_name"));
Selenide:
$("#customerContainer").find(".user_name");
Selenide > Keynote
Looking for Nth element
Selenium WebDriver:
driver.findElements(By.tagName("li")).get(5);
Selenide:
$("li", 5);
Selenide > Keynote
Select a radio button
Selenium WebDriver:
for (WebElement radio : driver.findElements(By.name("sex"))) {
if ("woman".equals(radio.getAttribute("value"))) {
radio.click();
}
}
throw new NoSuchElementException("'sex' radio field has no value 'woman'");
Selenide:
selectRadio(By.name("sex"), "woman");
Selenide > Keynote
Take a screenshot
Selenium WebDriver:
if (driver instanceof TakesScreenshot) {
File scrFile = ((TakesScreenshot) webdriver)
.getScreenshotAs(OutputType.FILE);
File targetFile = new File("c:temp" + fileName + ".png");
FileUtils.copyFile(scrFile, targetFile);
}
Selenide:
takeScreenShot("my-test-case");
Selenide > Three simple things
1. Open the page
2. $(element).doAction()
3. $(element).check(condition)
open("/login");
$("#submit").click();
$(".message").shouldHave(text("Hello"));
Selenide > Use the power of IDE
Selenide API consists of few classes. Open your IDE and start typing.
Just type: $(selector). - and IDE will suggest you all available options.
Use the power of todays development environments instead of bothering with
documentation!
Selenide > Selenide API
open(String URL) opens the browser (if yet not opened) and loads the
URL
$(String cssSelector) – returns object of the SelenideElement class that
represents first element found by CSS selector on the page.
$(By) – returns "first SelenideElement" by the locator of the By class.
$$(String cssSelector) – returns object of type ElementsCollection that
represents collection of all elements found by a CSS selector.
$$(By) – returns "collection of elements" by the locator of By type.
import static com.codeborne.selenide.Selenide.* for readability
Selenide > Selenide API > Selectors
com.codeborne.selenide.Selectors
$(byText("Login")).shouldBe(visible));
$(byXpath("//div[text()='Login']")).shouldBe(visible);
$(By.xpath("//div[text()='Login']")).shouldBe(visible);
Selector
byText - search element by exact text
withText - search element by contained text (substring)
by(attributeName, attributeValue) - search by attribute’s name and value
byTitle - search by attribute “title”
byValue - search by attribute “value”
Xpath
etc.
Selenide > Selenide API
Perform some action on it:
$(byText("Sign in")).click();
Or even several actions at once:
$(byName("password")).setValue("qwerty").pressEnter();
Check some condition:
$(".welcome-message").shouldHave(text("Welcome, user!"));
When you needed an element in Element Collection of a same type:
$$("#search-results a").findBy(text("selenide.org")).click();
Selenide > Selenide API > Selenide Elements
Selenide Elements
SelenideElement
ElementsCollection
$ $$
Selenide > Selenide API > Selenide Element
com.codeborne.selenide.SelenideElement
Actions methods
Search methods
Element statuses methods
Check methods (Assertions)
Conditions methods
Selenide Explicit Waits methods
Other useful methods
Selenide > Selenide API > Selenide Element
Actions methods
click()
doubleClick()
contextClick()
hover()
setValue(String) / val(String)
pressEnter()
pressEscape()
pressTab()
selectRadio(String value)
selectOption(String)
dragAndDropTo(String)
…
Search methods
find(String cssSelector)
/ $(String cssSelector)
find(By) / $(By)
findAll(String cssSelector)
/ $$(String cssSelector)
findAll(By) / $$(By)
Selenide > Selenide API > Selenide Element
Element statuses methods
getValue() / val()
data()
attr(String)
text()
innerText()
getSelectedOption()
getSelectedText()
getSelectedValue()
isDisplayed()
exists()
...
Check methods (Assertions)
should(Condition)
shouldBe(Condition)
shouldHave(Condition)
shouldNot(Condition)
shouldNotBe(Condition)
shouldNotHave(Condition)
Selenide > Selenide API > Selenide Element
Selenide Explicit Waits methods
waitUntil(Condition,
milliseconds)
waitWhile(Condition,
milliseconds)
Other useful methods
uploadFromClasspath(String
fileName)
download()
toWebElement()
uploadFile(File…)
Selenide > Selenide API > Selenide Element
com.codeborne.selenide.SelenideElement
Actions methods
Search methods
Element statuses methods
Check methods (Assertions)
Conditions methods
Selenide Explicit Waits methods
Other useful methods
● visible / appear
● present / exist
● hidden / disappear
● readonly
● name
● value
● type
● id
● empty
Selenide > Selenide API > Selenide Element
com.codeborne.selenide.Condition
$("input").shouldHave(exactText("Some text"));
Condition
● attribute(name)
● attribute(name, value)
● cssClass(String)
● focused
● enabled
● disabled
● selected
● matchText(String regex)
● text(String substring)
● exactText(String wholeText)
● textCaseSensitive(String substring)
● exactTextCaseSensitive(String wholeText)
Selenide > Selenide API > Selenide Elements
Selenide Elements
SelenideElement
ElementsCollection
$ $$
com.codeborne.selenide.ElementsCollection
Selector methods
Element statuses methods
Check methods (Assertions)
Conditions methods
Selenide > Selenide API > Elements Collection
Selenide > Selenide API > Elements Collection
Selector methods
filterBy(Condition) – returns
collection with only those
original collection elements
that satisfies the condition,
excludeWith(Condition)
get(int)
findBy(Condition)
Element statuses methods
size()
isEmpty()
getTexts()
Selenide > Selenide API > Elements Collection
Check methods (Assertions)
shouldBe(CollectionCondition)
shouldHave(CollectionCondition)
Assertions also play role of explicit waits.
They wait for condition
(e.g. size(2), empty, texts("a", "b", "c")) to be
satisfied until timeout reached (the value
of Configuration.collectionsTimeout
that is set to 6000 ms by default).
Conditions methods
empty
size(int)
sizeGreaterThan(int)
sizeGreaterThanOrEqual(int)
sizeLessThan(int)
sizeLessThanOrEqual(int)
sizeNotEqual(int)
texts(String... substrings)
exactTexts(String... wholeTexts)
Selenide > Selenide API > WebDriver Runner
com.codeborne.selenide.WebDriverRunner
This class defines some browser management methods:
isChrome()
isFirefox()
isHeadless()
url()
source()
getWebDriver() - returns the WebDriver instance (created by Selenide
automatically or set up by the user), thus giving to the user the raw API
to Selenium if needed
setWebDriver(WebDriver) - tells Selenide to use driver created by the
user. From this moment the user himself is responsible for closing the
driver.
Selenide > Selenide API > Configuration
com.codeborne.selenide.Configuration
Сonfiguration options to configure execution of Selenide-based tests, e.g.:
timeout: waiting timeout in milliseconds, that is used in explicit
(should/shouldNot/waitUntil/waitWhile) and implicit waiting for
SelenideElement; set to 4000 ms by default; can be changed for
specific tests, e.g. Configuration.timeout = 6000;
collectionsTimeout - waiting timeout in milliseconds, that is used in
explicit (should/shouldNot/waitUntil/waitWhile) and implicit waiting for
ElementsCollection; set to 6000 ms by default; can be changed for
specific tests, e.g. Configuration.collectionsTimeout = 8000;
browser (e.g. "chrome", "ie", "firefox")
baseUrl
...
UI Test Automation Framework
Selenium inside
http://jdi.epam.com
https://github.com/epam/JDI
https://github.com/epam/JDI-Examples
JDI > Main Goals
Already implemented actions for most used elements
Detailed UI actions log
Flexible for any UI on any Framework or Platform
Short and obvious UI Objects (Page Objects)
JDI > Simple Test
loginPage.open();
loginPage.loginForm.login(admin);
searchPage.search.find("Cup");
Assert.AreEqual(
resultsPage.products.count(),
expected);
JDI > Simple Test
productPage.productType.Select("jacket");
productPage.price.select("500$");
productPage.colors.check("black", "white");
Assert.isTrue(
productPage.label.getText(),
"Massimo Dutti Jacket")
JDI > JDI API
Elements
Simple
Complex
Composite
JDI > JDI API
Simple Elements
JDI > JDI API > Simple Elements
JDI > JDI API > Simple Elements
JDI > JDI API > Multilocators
JDI > JDI API
Complex Elements
JDI > JDI API > Complex Elements
JDI > JDI API > Complex Elements
JDI > JDI API > Complex Elements
JDI > JDI API > Complex Elements > Enums
JDI > JDI API > Typified elements
Code readability
Clear behavior
Union of all element’s locators
Union of element and its actions
Detailed logging
JDI > JDI API > Compare
JDI > JDI API > Compare
JDI > JDI API
Composite Elements
JDI > JDI API > Composite Elements
JDI > JDI API > Web Site
JDI > JDI API > Web Page
JDI > JDI API > Section
JDI
UI Objects Pattern
JDI > UI Objects Pattern
JDI > UI Objects Pattern
JDI
Interfaces
JDI > Test Any UI
JDI > Architecture
JDI > Interfaces
JDI
Selenide vs JDI > Language support
Native JNI Selene
Native Native
Not
supported

More Related Content

PPTX
Write Selenide in Python 15 min
PDF
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
PDF
Kiss PageObjects [01-2017]
PDF
Efficient Rails Test-Driven Development - Week 6
PDF
Efficient Rails Test Driven Development (class 3) by Wolfram Arnold
PDF
Efficient Rails Test Driven Development (class 4) by Wolfram Arnold
PDF
Easy tests with Selenide and Easyb
PDF
Introduction to Selenium and Ruby
Write Selenide in Python 15 min
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Kiss PageObjects [01-2017]
Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test Driven Development (class 3) by Wolfram Arnold
Efficient Rails Test Driven Development (class 4) by Wolfram Arnold
Easy tests with Selenide and Easyb
Introduction to Selenium and Ruby

What's hot (19)

PPT
Spring batch
PDF
Top100summit 谷歌-scott-improve your automated web application testing
PDF
XpDays - Automated testing of responsive design (GalenFramework)
PDF
Introduction to Sightly
ODP
Codegnitorppt
PDF
Polyglot automation - QA Fest - 2015
PPTX
Galen Framework - Responsive Design Automation
PDF
Breaking the limits_of_page_objects
PPT
Android | Busy Java Developers Guide to Android: UI | Ted Neward
PPTX
Selenium withnet
PDF
Selenium - The page object pattern
PPTX
Selenium locators: ID, Name, xpath, CSS Selector advance methods
PPTX
Scaladays 2014 introduction to scalatest selenium dsl
PDF
Webdriver cheatsheets summary
PDF
AtlasCamp 2015: Web technologies you should be using now
PDF
Easy automation.py
PDF
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
PDF
AtlasCamp 2015: Connect everywhere - Cloud and Server
PPTX
Protractor framework – how to make stable e2e tests for Angular applications
Spring batch
Top100summit 谷歌-scott-improve your automated web application testing
XpDays - Automated testing of responsive design (GalenFramework)
Introduction to Sightly
Codegnitorppt
Polyglot automation - QA Fest - 2015
Galen Framework - Responsive Design Automation
Breaking the limits_of_page_objects
Android | Busy Java Developers Guide to Android: UI | Ted Neward
Selenium withnet
Selenium - The page object pattern
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Scaladays 2014 introduction to scalatest selenium dsl
Webdriver cheatsheets summary
AtlasCamp 2015: Web technologies you should be using now
Easy automation.py
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
AtlasCamp 2015: Connect everywhere - Cloud and Server
Protractor framework – how to make stable e2e tests for Angular applications
Ad

Similar to Escape from the automation hell (20)

PDF
Selenide
PDF
Selenium - Introduction
PDF
Selenium Automation Testing - A Complete Guide.pdf
PDF
Selenium Automation Testing - A Complete Guide
PPTX
Automated Web Testing With Selenium
PPTX
Selenium web driver
PPTX
Selenium Automation
PPT
Selenium
PDF
Selenium Automation Testing - A Complete Guide.pdf
PDF
Automation Testing using Selenium Webdriver
PPT
Selenium Concepts
PDF
Web UI test automation instruments
PDF
Selenium for Tester.pdf
PPTX
Selenium web driver
PPTX
Selenium Automation
PPTX
PPT
Selenium Primer
PPTX
Automated testing using Selenium & NUnit
PPTX
Selenium.pptx
PPT
Selenium Java for Beginners by Sujit Pathak
Selenide
Selenium - Introduction
Selenium Automation Testing - A Complete Guide.pdf
Selenium Automation Testing - A Complete Guide
Automated Web Testing With Selenium
Selenium web driver
Selenium Automation
Selenium
Selenium Automation Testing - A Complete Guide.pdf
Automation Testing using Selenium Webdriver
Selenium Concepts
Web UI test automation instruments
Selenium for Tester.pdf
Selenium web driver
Selenium Automation
Selenium Primer
Automated testing using Selenium & NUnit
Selenium.pptx
Selenium Java for Beginners by Sujit Pathak
Ad

Recently uploaded (20)

PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PPTX
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
PDF
Workplace Software and Skills - OpenStax
PPTX
Trending Python Topics for Data Visualization in 2025
PDF
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
PPTX
Tech Workshop Escape Room Tech Workshop
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PDF
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PDF
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero
PDF
Visual explanation of Dijkstra's Algorithm using Python
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PDF
Guide to Food Delivery App Development.pdf
DOC
UTEP毕业证学历认证,宾夕法尼亚克拉里恩大学毕业证未毕业
PPTX
most interesting chapter in the world ppt
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PPTX
Airline CRS | Airline CRS Systems | CRS System
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
PPTX
Cybersecurity-and-Fraud-Protecting-Your-Digital-Life.pptx
PDF
Topaz Photo AI Crack New Download (Latest 2025)
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
4Seller: The All-in-One Multi-Channel E-Commerce Management Platform for Glob...
Workplace Software and Skills - OpenStax
Trending Python Topics for Data Visualization in 2025
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
Tech Workshop Escape Room Tech Workshop
Wondershare Recoverit Full Crack New Version (Latest 2025)
novaPDF Pro 11.9.482 Crack + License Key [Latest 2025]
DNT Brochure 2025 – ISV Solutions @ D365
Type Class Derivation in Scala 3 - Jose Luis Pintado Barbero
Visual explanation of Dijkstra's Algorithm using Python
How to Use SharePoint as an ISO-Compliant Document Management System
Guide to Food Delivery App Development.pdf
UTEP毕业证学历认证,宾夕法尼亚克拉里恩大学毕业证未毕业
most interesting chapter in the world ppt
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
Airline CRS | Airline CRS Systems | CRS System
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
Cybersecurity-and-Fraud-Protecting-Your-Digital-Life.pptx
Topaz Photo AI Crack New Download (Latest 2025)

Escape from the automation hell

  • 4. DSL A domain-specific language (DSL) is a computer language specialized to a particular application domain. @Test public void bookShouldBeSearchedByName() { loginToBookStoreAs(regularUser); openBookStorePage(); enterSearchCriteria("99 Francs"); searchBooks(); assertFalse(isEmptySearchResult()); }
  • 5. Benefits of DSL Approach ● High-level - tests are in the language of product management, at the user level ● Readable - product management can understand them ● Writable - easy for developer or QA to write new test ● Extensible - tests base is able to grow with DSL
  • 6. Tips and Tricks of DSL Approach ● Use test class hierarchy or test helpers ● Use builders, visitors and other design patterns ● Reuse domain model from application ● Some common methods move to base test class ● Minimize usage of driver instance in tests
  • 7. What is really Test Automation Framework? Test Automation Framework (TAF) — the environment required for test automation including test harnesses and artifacts such as test libraries. Test Automation Solution (TAS) — the realization / implementation of a TAA including test harnesses and artifacts such as test libraries. Test Automation Architecture (TAA) — an instantiation of gTAA to define the architecture of a TAS. Generic Test Automation Architecture (gTAA) — providing a blueprint for test automation solutions.
  • 8. What is really Test Automation Framework?
  • 9. What is Test Automation Engineer? Test Automation Engineer (TAE) — the person who is responsible for the design of a Test Automation Architecture (TAA), including the implementation of the resulting Test Automation Solution (TAS), its maintenance and technical evolution. TAE == Software Developer in Test
  • 10. What is really WebDriver? Selenium is a suite of tools to automate web browsers across many platforms.
  • 11. What is really WebDriver? Selenium automates browsers. That's it!
  • 12. UI Test Automation Framework Selenium inside http://selenide.org https://github.com/codeborne/selenide
  • 13. Selenide > Main Goals KISS principle in action No unnecessary code → No unnecessary maintenance Less to learn → Easier to use
  • 14. Selenide > Keynote Create a browser Selenium WebDriver: DesiredCapabilities desiredCapabilities = DesiredCapabilities.htmlUnit(); desiredCapabilities.setCapability(HtmlUnitDriver.INVALIDSELECTIONERROR, true); desiredCapabilities.setCapability(HtmlUnitDriver.INVALIDXPATHERROR, false); desiredCapabilities.setJavascriptEnabled(true); WebDriver driver = new HtmlUnitDriver(desiredCapabilities); Selenide: open("https://catalog.onliner.by");
  • 15. Selenide > Keynote Shutdown a browser Selenium WebDriver: if (driver != null) { driver.close(); } Selenide: // Do not care! Selenide closes the browser automatically With Selenide You don't need to operate with Selenium WebDriver directly. WebDriver will be automatically created/deleted during test start/finished.
  • 16. Selenide > Keynote Find element by id Selenium WebDriver: WebElement customer = driver.findElement(By.id("customerContainer")); Selenide: WebElement customer = $("#customerContainer"); or a longer conservative option: WebElement customer = $(By.id("customerContainer"));
  • 17. Selenide > Keynote Assert that element has a correct text Selenium WebDriver: assertEquals("Customer profile", driver.findElement(By.id("customerContainer")).getText()); Selenide: $("#customerContainer").shouldHave(text("Customer profile"));
  • 18. Selenide > Keynote Ajax support (waiting for some event to happen) Selenium WebDriver: FluentWait<By> fluentWait = new FluentWait<By>(By.tagName("TEXTAREA")); fluentWait.pollingEvery(100, TimeUnit.MILLISECONDS); fluentWait.withTimeout(1000, TimeUnit.MILLISECONDS); fluentWait.until(new Predicate<By>() { public boolean apply(By by) { try { return browser.findElement(by).isDisplayed(); } catch (NoSuchElementException ex) { return false; } } }); assertEquals("John", browser.findElement(By.tagName("TEXTAREA")).getAttribute("value")); Selenide: $("TEXTAREA").shouldHave(value("John")); This command automatically waits until element gets visible AND gets expected value. Default timeout is 4 seconds and it's configurable.
  • 19. Selenide > Keynote Assert that element does not exist Selenium WebDriver: try { WebElement element = driver.findElement(By.id("customerContainer")); fail("Element should not exist: " + element); } catch (WebDriverException itsOk) {} Selenide: $("#customerContainer").shouldNot(exist);
  • 20. Selenide > Keynote Looking for element inside parent element Selenium WebDriver: WebElement parent = driver.findElement(By.id("customerContainer")); WebElement element = parent.findElement(By.className("user_name")); Selenide: $("#customerContainer").find(".user_name");
  • 21. Selenide > Keynote Looking for Nth element Selenium WebDriver: driver.findElements(By.tagName("li")).get(5); Selenide: $("li", 5);
  • 22. Selenide > Keynote Select a radio button Selenium WebDriver: for (WebElement radio : driver.findElements(By.name("sex"))) { if ("woman".equals(radio.getAttribute("value"))) { radio.click(); } } throw new NoSuchElementException("'sex' radio field has no value 'woman'"); Selenide: selectRadio(By.name("sex"), "woman");
  • 23. Selenide > Keynote Take a screenshot Selenium WebDriver: if (driver instanceof TakesScreenshot) { File scrFile = ((TakesScreenshot) webdriver) .getScreenshotAs(OutputType.FILE); File targetFile = new File("c:temp" + fileName + ".png"); FileUtils.copyFile(scrFile, targetFile); } Selenide: takeScreenShot("my-test-case");
  • 24. Selenide > Three simple things 1. Open the page 2. $(element).doAction() 3. $(element).check(condition) open("/login"); $("#submit").click(); $(".message").shouldHave(text("Hello"));
  • 25. Selenide > Use the power of IDE Selenide API consists of few classes. Open your IDE and start typing. Just type: $(selector). - and IDE will suggest you all available options. Use the power of todays development environments instead of bothering with documentation!
  • 26. Selenide > Selenide API open(String URL) opens the browser (if yet not opened) and loads the URL $(String cssSelector) – returns object of the SelenideElement class that represents first element found by CSS selector on the page. $(By) – returns "first SelenideElement" by the locator of the By class. $$(String cssSelector) – returns object of type ElementsCollection that represents collection of all elements found by a CSS selector. $$(By) – returns "collection of elements" by the locator of By type. import static com.codeborne.selenide.Selenide.* for readability
  • 27. Selenide > Selenide API > Selectors com.codeborne.selenide.Selectors $(byText("Login")).shouldBe(visible)); $(byXpath("//div[text()='Login']")).shouldBe(visible); $(By.xpath("//div[text()='Login']")).shouldBe(visible); Selector byText - search element by exact text withText - search element by contained text (substring) by(attributeName, attributeValue) - search by attribute’s name and value byTitle - search by attribute “title” byValue - search by attribute “value” Xpath etc.
  • 28. Selenide > Selenide API Perform some action on it: $(byText("Sign in")).click(); Or even several actions at once: $(byName("password")).setValue("qwerty").pressEnter(); Check some condition: $(".welcome-message").shouldHave(text("Welcome, user!")); When you needed an element in Element Collection of a same type: $$("#search-results a").findBy(text("selenide.org")).click();
  • 29. Selenide > Selenide API > Selenide Elements Selenide Elements SelenideElement ElementsCollection $ $$
  • 30. Selenide > Selenide API > Selenide Element com.codeborne.selenide.SelenideElement Actions methods Search methods Element statuses methods Check methods (Assertions) Conditions methods Selenide Explicit Waits methods Other useful methods
  • 31. Selenide > Selenide API > Selenide Element Actions methods click() doubleClick() contextClick() hover() setValue(String) / val(String) pressEnter() pressEscape() pressTab() selectRadio(String value) selectOption(String) dragAndDropTo(String) … Search methods find(String cssSelector) / $(String cssSelector) find(By) / $(By) findAll(String cssSelector) / $$(String cssSelector) findAll(By) / $$(By)
  • 32. Selenide > Selenide API > Selenide Element Element statuses methods getValue() / val() data() attr(String) text() innerText() getSelectedOption() getSelectedText() getSelectedValue() isDisplayed() exists() ... Check methods (Assertions) should(Condition) shouldBe(Condition) shouldHave(Condition) shouldNot(Condition) shouldNotBe(Condition) shouldNotHave(Condition)
  • 33. Selenide > Selenide API > Selenide Element Selenide Explicit Waits methods waitUntil(Condition, milliseconds) waitWhile(Condition, milliseconds) Other useful methods uploadFromClasspath(String fileName) download() toWebElement() uploadFile(File…)
  • 34. Selenide > Selenide API > Selenide Element com.codeborne.selenide.SelenideElement Actions methods Search methods Element statuses methods Check methods (Assertions) Conditions methods Selenide Explicit Waits methods Other useful methods
  • 35. ● visible / appear ● present / exist ● hidden / disappear ● readonly ● name ● value ● type ● id ● empty Selenide > Selenide API > Selenide Element com.codeborne.selenide.Condition $("input").shouldHave(exactText("Some text")); Condition ● attribute(name) ● attribute(name, value) ● cssClass(String) ● focused ● enabled ● disabled ● selected ● matchText(String regex) ● text(String substring) ● exactText(String wholeText) ● textCaseSensitive(String substring) ● exactTextCaseSensitive(String wholeText)
  • 36. Selenide > Selenide API > Selenide Elements Selenide Elements SelenideElement ElementsCollection $ $$
  • 37. com.codeborne.selenide.ElementsCollection Selector methods Element statuses methods Check methods (Assertions) Conditions methods Selenide > Selenide API > Elements Collection
  • 38. Selenide > Selenide API > Elements Collection Selector methods filterBy(Condition) – returns collection with only those original collection elements that satisfies the condition, excludeWith(Condition) get(int) findBy(Condition) Element statuses methods size() isEmpty() getTexts()
  • 39. Selenide > Selenide API > Elements Collection Check methods (Assertions) shouldBe(CollectionCondition) shouldHave(CollectionCondition) Assertions also play role of explicit waits. They wait for condition (e.g. size(2), empty, texts("a", "b", "c")) to be satisfied until timeout reached (the value of Configuration.collectionsTimeout that is set to 6000 ms by default). Conditions methods empty size(int) sizeGreaterThan(int) sizeGreaterThanOrEqual(int) sizeLessThan(int) sizeLessThanOrEqual(int) sizeNotEqual(int) texts(String... substrings) exactTexts(String... wholeTexts)
  • 40. Selenide > Selenide API > WebDriver Runner com.codeborne.selenide.WebDriverRunner This class defines some browser management methods: isChrome() isFirefox() isHeadless() url() source() getWebDriver() - returns the WebDriver instance (created by Selenide automatically or set up by the user), thus giving to the user the raw API to Selenium if needed setWebDriver(WebDriver) - tells Selenide to use driver created by the user. From this moment the user himself is responsible for closing the driver.
  • 41. Selenide > Selenide API > Configuration com.codeborne.selenide.Configuration Сonfiguration options to configure execution of Selenide-based tests, e.g.: timeout: waiting timeout in milliseconds, that is used in explicit (should/shouldNot/waitUntil/waitWhile) and implicit waiting for SelenideElement; set to 4000 ms by default; can be changed for specific tests, e.g. Configuration.timeout = 6000; collectionsTimeout - waiting timeout in milliseconds, that is used in explicit (should/shouldNot/waitUntil/waitWhile) and implicit waiting for ElementsCollection; set to 6000 ms by default; can be changed for specific tests, e.g. Configuration.collectionsTimeout = 8000; browser (e.g. "chrome", "ie", "firefox") baseUrl ...
  • 42. UI Test Automation Framework Selenium inside http://jdi.epam.com https://github.com/epam/JDI https://github.com/epam/JDI-Examples
  • 43. JDI > Main Goals Already implemented actions for most used elements Detailed UI actions log Flexible for any UI on any Framework or Platform Short and obvious UI Objects (Page Objects)
  • 44. JDI > Simple Test loginPage.open(); loginPage.loginForm.login(admin); searchPage.search.find("Cup"); Assert.AreEqual( resultsPage.products.count(), expected);
  • 45. JDI > Simple Test productPage.productType.Select("jacket"); productPage.price.select("500$"); productPage.colors.check("black", "white"); Assert.isTrue( productPage.label.getText(), "Massimo Dutti Jacket")
  • 46. JDI > JDI API Elements Simple Complex Composite
  • 47. JDI > JDI API Simple Elements
  • 48. JDI > JDI API > Simple Elements
  • 49. JDI > JDI API > Simple Elements
  • 50. JDI > JDI API > Multilocators
  • 51. JDI > JDI API Complex Elements
  • 52. JDI > JDI API > Complex Elements
  • 53. JDI > JDI API > Complex Elements
  • 54. JDI > JDI API > Complex Elements
  • 55. JDI > JDI API > Complex Elements > Enums
  • 56. JDI > JDI API > Typified elements Code readability Clear behavior Union of all element’s locators Union of element and its actions Detailed logging
  • 57. JDI > JDI API > Compare
  • 58. JDI > JDI API > Compare
  • 59. JDI > JDI API Composite Elements
  • 60. JDI > JDI API > Composite Elements
  • 61. JDI > JDI API > Web Site
  • 62. JDI > JDI API > Web Page
  • 63. JDI > JDI API > Section
  • 65. JDI > UI Objects Pattern
  • 66. JDI > UI Objects Pattern
  • 68. JDI > Test Any UI
  • 71. JDI
  • 72. Selenide vs JDI > Language support Native JNI Selene Native Native Not supported