What is the taste of the Selenide

Post on 06-Apr-2017

68 views 0 download

Transcript of What is the taste of the Selenide

What is the taste of

the Selenide?MARINSKY ROMA

TICKETS.UA

Selenium

Selenium is an umbrella project encapsulating a variety

of tools and libraries enabling web browser automation

WebDriver, Selenium IDE, Selenium Grid

W3C WebDriver specification

Selenium

Need allot of boilerplate for:

Init browsers

Wait for availability of any elements

Screenshots

Logs

Upload and download files

PageObject and PageFactory

Wrapper around Selenium WebDriver not a framework

Fluent API for simple using all features

Supporting AJAX for stable tests, forgot: StaleElementExaptions

Simple waiting for any conditions for each element

Multifunctional Selectors

Simple Configurations for project with tests

UI Tests: Selenide

Selenide.class

$(css), $(By by), $x(xpath), $(By, index)

$$(css), $$(By by), $$x(xpath)

open(…) //URL, Login, PF

selectRadio(By, withText)

switchTo()

page() //for PageFactory *initElements(.class)*

Selenide.class

executeJavaScript()

actions()

Wait()

clearAllCookies()

clearLocalStorage()

zoom()

screenshot()

SelenideElement actions

followLink(), click(), contextClick()

setValue(string), val(), append()

uploadFile()

selectOption(By, text)

scrollTo(), hover(), dragAndDrop()

getText(), getValue(), getAttribute()

Should’ы and Wait’ы

should(Condition condition)

shouldHave()

shouldBe()

shouldNot(Condition condition)

shouldNotHave()

shouldNotBe()

waitUntil(Condition, timeout, pooling)

waitWhile(Condition, timeout, pooling)

waitUntil(Condition, timeout)

waitWhile(Condition, timeout)

ElementCollection actions

shouldHaveSize(Condition)

get(index), first(), last()

filter(Condition), filterBy(Condition) -> collection

find(Condition), findBy(Condition) -> element

exclude(Condition), excludeBy(Condition)

Conditions

visible, appear

exist, present

hidden, disappear

attribute(), attribute(name, value)

value(), name(), type(), id(), cssClass()

empty

matchText(regex), text(), exactText(), textCaseSensitive(), exactTextCaseSensitive()

focused, enabled, disabled,

selected, checked, readOnly

not(Condition), and(because,Condition),

or(because, Condition), be(), have()

CollectionConditions

get()

size(), sizeGreaterThan(),

sizeGreaterThanOrEqual()

sizeLessThan(),

sizeLessThanOrEqaul(), sizeNotEqual()

texts(…), exactTexts(…)

empty

WebDriverRunner

isFirefox, isHtmlUnit, isChrome, isSafari,

isHeadless, isEdge…

source()

url(), currentFrameUrl()

clearBrowserCache()

supportsModalDialogs(),

supportsJavascript()

Browser name constants(chrome,ff...)

addListeners(WebDriverEventListener)

setWebDriver(customDriver),

closeWebDriver()

getWebDriver(),

getAndCheckWebDriver(),

hasWebDriverStarted()

setProxy()

Configuration

clickViaJs, fastSetValue

captureJsErrors

screenshots, savePageSource,

reportFolder, reportsUrl

dismissModalDialogs

selectorMode [css, sizzle]

assertionMode [soft, strict]

fileDownload [httpget, proxy]

baseUrl, browser

timeout, collectionTimeout

poolingInterval,

coollectionPoolingInterval

holdBrowserOpen,

reopenBrowserOnFail,

closeBrowserMs

remote

browserSize, startMaximized

Extra selectors and parent

selectors withText(), byText()

byAttribute(), by()

byTitle(), byValue(), byId(), byName()

byXpath()

byLinkText(), byPartialLinkText()

byCssSelector()

byClassName

$(“tr td.dig”).parent()

$(“tr td.dig”).closest(“th”)

Bonus features #1

Configuration.fileDownload = PROXY;

File testFile = $(“#file”).download();

Download files via proxy

Use when form have no href or other url

for start downloading file

Download file starts after click on the

form.

Will starts proxy server witch intercepts

downloading files

Bonus features #2

You can use:

LoginForm loginForm = new LoginForm();

loginForm.submit.click();

Instead of:

LoginForm loginForm = page(LoginForm.class);

loginForm.submit.click();

Selenide PageFactory

You can use:

SelenideElement submit = $(“#submit”),

loginInput = $(“input.login”);

Instead of:

@FindBy(css=“#submit”)

SelenideElement submit;

@FindBy(css=“input.login”)

SelenideElement loginInput;

Bonus features #3

Simple Logger

When you need logging all element actions do not use log4j and others

Use:

@Rule || @Listener

public TextReport = new TextReport();

Or

new TextReport().onFailedTest(true)

.onSucceededTest(false)

Bonus features #4

Screenshots

When you need screenshots on each

fail test or more

Use:@Rule || @Listenerpublic ScreenShooter = ScreenShooter.failedTests();

Or: ScreenShooter.failedTests(). succeededTests();

How to start?

Include dependencies: selenide & webdrivermanager

Use static imports for Selenide’s methods

Keep it simple stupid!

WebDriver Manager

https://github.com/bonigarcia/webdrivermanager

Myths about Selenide

Will be it enterprise? – No

Selenide will do tests slower! – No

Need to know Selenium at the first! – No

Selenide it isn’t OOP framework! – No

Does not have typed elements! – So what?

It’s boilerplate

Links & contacts

github.com/rmarinsky

fb.com/newromka

ru.selenide.org

software-testers.herokuapp.com

automated-testing.info/

Thank you for attention

Questions?