Successfully reported this slideshow.
Your SlideShare is downloading. ×

Selenide review and how to start using it in legacy Selenium tests

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 23 Ad

More Related Content

Similar to Selenide review and how to start using it in legacy Selenium tests (20)

Advertisement

More from Provectus (20)

Recently uploaded (20)

Advertisement

Selenide review and how to start using it in legacy Selenium tests

  1. 1. Selenide Review And How To Start Using It In Legacy Selenium Tests Alex, QA Automation (UI + API), Determine
  2. 2. Plan 1)What is Selenide? 2)Selenide quirks and features 3)Do you need Selenide? 4)Demo 5)Questions
  3. 3. What is Selenide?
  4. 4. Simple selectors Selenide $(WebElement) $(By) $(String) Selenium Webelement WebDriver.findElement(By) WebDriver.findElement(By.cssSelector(String))
  5. 5. .$x(xpath) Selenide can do $("table").$x(".//tr") $("table").$$x(".//tr") When Selenium needs WebDriver.findElement(By.cssSelector("table")).findElement(By.xpath(".//tr")); WebDriver.findElement(By.cssSelector("table")).findElements(By.xpath(".//tr"));
  6. 6. Other selectors $(byText("Logout")); // search by exact text $(withText("Logout")); // search by text (substring) $(byTitle("Logout")); // search by "title" attribute $(byAttribute("class", "g")); // search by attribute $(byValue("example")); // search by "value" attribute
  7. 7. Scoping selectors $("#mainElement").$("#subElement"); $("#customerContainer").find(".user_name"); $("li", 5); // looking for Nth element $$("li").get(5);
  8. 8. Clicking actions $("#submit").click(); $(".g").doubleClick(); $(".g").contextClick(); $("q").pressEnter(); $("q").pressTab();
  9. 9. Form actions $("#login").setValue("John Doe"); $(".menu").selectOption(String text); $(By.name("menu")).selectOptionByValue(String value); selectRadio(By.name("user.gender"), "male"); $("#element")).hover();
  10. 10. Text Assertions && deal with Ajax $("#element").shouldHave(text("abc")); $("h1").shouldHave(exactText("Hello")) $("h1").shouldHave(textCaseSensitive("Hellos*John")); $("h1").shouldHave(exactTextCaseSensitive("Hello")); $("#input").shouldNotHave(text("Hello"), text("World"));
  11. 11. Attribute Assertions && deal with Ajax $("h1").shouldHave(css("font-size", "16px")); $("#input").shouldHave(name("fname")); $("#input").shouldHave(type("checkbox")); $("#input").shouldHave(id("myForm")); $("#input").shouldHave(attribute("id"[, "myForm"]));
  12. 12. My Favorite Assertions && deal with Ajax $("input").shouldBe(visible, enabled); //visible | appear $("input").shouldNotBe(visible, enabled); $("input").shouldBe(not(visible, enabled)); $("input").shouldBe(exist); //present | exist $("input").shouldBe(hidden); //hidden | disappear | not(visible) $("input").shouldBe(readonly); $("input").shouldBe(focused); $(".errors").shouldBe(empty); $("#element").should(exist);
  13. 13. Collections Assertions && deal with Ajax $$(".errors").shouldHave(size(2)); $$("gs-title").shouldHave(sizeGreaterThan(5)); $$(".errors").shouldBe(empty); $$(".errors").shouldHave(exactTexts("text 1", "text 2")); $$(".errors").shouldHave(texts("text 1", "text 2"));
  14. 14. should... vs. waitUntil should(...) == shouldBe(...) == shouldHave(...) → Synonyms shouldNot(...) == shouldNotBe(...) == shouldNotHave(...) → Synonyms Their timeout is set by Selenide configuration. For specific timeout use: $("#username").waitUntil(matchesText("Johny"), 2000); $("#username").waitUntil(not(matchesText("Noname")), 2000); $("#username").waitUntil(visible, 5000); For instant boolean verification use: $("#username").is(visible);
  15. 15. Configuration Configuration.timeout Configuration.pollingInterval Configuration.pageLoadStrategy // (none | normal | eager) Configuration.startMaximized Configuration.browser = "marionette" ...
  16. 16. WebDriverRunner WebDriverRunner.source(); //returns source HTML code of current page WebDriverRunner.getWebDriver(); WebDriverRunner.setWebDriver(customWebDriver); ...
  17. 17. Add Selenium to project: 1. Open Selenide Quick Starts and use hints 2. For Legacy project use: a. WebDriverRunner.setWebDriver(yourDriver); 3. Wrap WebElement in $(...) → $(legacyElement) 4. Start using full power of Selenide
  18. 18. Do you need Selenide ? Search “good code vs bad code” for this img.
  19. 19. Make tests more readable $$(summaryResults).shouldHave(sizeGreaterThan(0)) .filter(Condition.visible).first().getText(); SelenideElement table = $(byText("First name")).closest(".v-table"); table.findAll(".v-table-header .v-table-header-cell") .shouldHave(texts("First name", "Last name", "Email", "Phone number" , "Street Address", "Postal Code", "City"));
  20. 20. Frequent Updates 1)https://github.com/codeborne/selenide 2)50 releases 3)34 contributors 4)asolntsev committed on GitHub 2 days ago (by September 13)
  21. 21. Demo
  22. 22. Questions? Usefull links: This demo: https://github.com/alex-d-bondarev/selenide-demo Selenide Quick Start: http://selenide.org/quick-start.html Selenide Cheat Sheet https://gist.github.com/mkpythonanywhereblog/947633ba1bf0bc239639 Selenide Examples https://github.com/selenide-examples
  23. 23. Thanks! Contact me: Oleksandr Bondarev alex.d.bondarev@gmail.com

×