Selenide is an open source software testing tool for writing
concise, expressive and stable UI tests in Java.
Selenide resolves all the typical problems with testing of modern web applications like Ajax and timeouts in a simple and elegant way.
Selenide is extremely simple to start with: you don't need to read hundreds-pages-long tutorials.
Just open IDE and start writing. Learning curve is close to zero. With Selenide you don't waste time on googling "how to make Selenium do that" - you can concentrate on business logic.
Selenide = a better Selenium
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Weekly Webinars on Test Automation with Selenide
1. Lockdown Technical Webinars
Weekly Webinars for Undergraduates while in Lockdown
Test Automation with Selenide
Corporate Sponsors
Corporate SponsorsKnowledge PartnerOrganized by
7. Step 1
Selenide comes to us as a java library
You can either,
1. Use the library by directly adding that to your selenium java project as an
external.jar file or
2. You can use the maven dependency related to the selenide library in your
maven project.
Either way you can enjoy the powers of Selenide !
8. Step 1
You can download the .jar file using below link
https://search.maven.org/search?q=g:com.codeborne%20AND%20a:selenide
Or Maven dependency from here
https://selenide.org/quick-start.html
12. Selectors & Main Methods
• $(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.
13. Contd …
Usually, when you get a SelenideElement object by the Dollar $ command, you can
• perform some action on it:
$(byText("Sign in")).click();
• or even several actions at once:
$(byName("password")).setValue("qwerty").pressEnter();
• or you can check some condition:
$(".welcome-message").shouldHave(text("Welcome, user!"))
14. Contd …
"Double Dollar" command ( $$ ) can be useful when a needed element is a one of a
same type.
For example, instead of:
$(byXpath("//*[@id='search-results']//a[contains(text(),'selenide.org')]")).click();
you can use more readable and verbose alternative:
$$("#search-results a").findBy(text("selenide.org")).click();
You perform the same action BUT 2nd method will increase
• Readability
• Debuggability
18. Selenide Element !
The “SelenideElement” class is a wrapper over Selenium WebElement that adds
some rather useful methods
It’s a proxy element !
You can,
• Access the inner element
• Check the state
• Perform actions
• Access element attributes
19. Contd …!
Both $ and $$ methods returns,
Proxy elements
Hence,
It doesn’t need to be real at the beginning
Thus,
You can create a locator chain
$("#header").find("#menu").findAll(".item")
20. Contd …!
You can perform following actions on the selenide elements
• click()
• doubleClick()
• contextClick()
• hover()
• setValue(String) | val(String)
• pressEnter()
• pressEscape()
• pressTab()
• selectRadio(String value)
• selectOption(String)
• append(String)
• dragAndDropTo(String)
And many more …
21. Contd …!
You can get selenide element statuses via following methods …
• getValue() | val()
• data()
• attr(String)
• text() // returns "visible text on a page"
• innerText() // returns "text of element in DOM"
• getSelectedOption()
• getSelectedText()
• getSelectedValue()
•
And many more …
23. Selenide Conditions
You can impose different types of conditions on selenide elements via
Should(Condition …)
ShouldBe(Condition …)
ShouldHave(Condition …)
ShouldNot(Condition …)
And few more …
24. Contd …
visible | appear // e.g. $("input").shouldBe(visible) (instead of
$("input").shouldBe(Condition.visible))
present | exist // conditions to wait for element existence in DOM (it can be still
hidden)
hidden | disappear | not(visible)
readonly // e.g. $("input").shouldBe(readonly)
name // e.g. $("input").shouldHave(name("fname"))
And many more …
26. Selectors
• byText - search element by exact text
• withText - search element by contained text (substring)
• byTitle - search by attribute "title"
• byValue - search by attribute "value"
• by(attributeName, attributeValue) - search by attribute's name and value
• byXpath
• etc.
28. Element Collections
The object of this class is also a "proxy", the same way as object of SelenideElement
class. This object can be created by calling the $$ method and represents the list of
web-elements on the page.
Assertions on collections
Trigger the search of the actual elements on the page for the proxy-collection,
performs the check based on collection condition, returns the object of
ElementsCollection class
$$(".errors").shouldBe(empty)
$$("#mytable tbody tr").shouldHave(size(2))
29. Contd
Methods to get statues and attributes of elements collection
size()
isEmpty()
getTexts() - e.g - <li>a</li><li hidden>b</li><li>c</li> OUTPUT ?
30. Contd
Methods-selectors of specific collection elements
filterBy(Condition) e.g - $$("#multirowTable tr").filterBy(text("Norris"))
excludeWith(Condition) - e.g. $$("#multirowTable tr").excludeWith(text("Chuck"))
get(int)
findBy(Condition) - OUTPUT – element ? Element collection ?
31. Contd
Collection Conditions
Collection conditions are used in the shouldBe/shouldHave constructs for the
object of ElementsCollection class
• empty // e.g. $$("#list li").shouldBe(empty)
• size(int) // e.g. $$("#list li").shouldHave(size(10))
• sizeGreaterThan(int)
• sizeGreaterThanOrEqual(int)
• sizeLessThan(int) sizeLessThanOrEqual(int)
And some more …
33. WebDriver Runner
This class defines some browser management methods:
isChrome()
isFirefox()
isHeadless()
url() - returns current url
source() - returns source HTML code of current page
34. WebDriver Runner
If in case, you want to access the raw selenium
getWebDriver()
setWebDriver(WebDriver)