Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

BDD With Selenide by Hima Bindu Peteti

196 views

Published on

Selenide is an open source library that can make a huge impact and accelerate software delivery by introducing concise API, shorter expressions and many other capabilities. In this SauceCon 2019 presentation, Hima Bindu Peteti explains:

- Key features of Selenide that can be used to make automation code simpler, easier to read and more maintainable

- The most effective test automation design patterns with Selenide

- Selenide support for Angular-based applications and other advanced Javascript libraries

- How to use Selenide with Cucumber for BDD

- Execution and generation of reports

Published in: Software
  • Be the first to comment

BDD With Selenide by Hima Bindu Peteti

  1. 1. Fannie Mae Confidential and Proprietary BDD With Selenide Hima Bindu Peteti Saucecon 2019
  2. 2. 0 2 HIMA BINDU PETETI Senior Software Engineer Experienced in designing and developing large scale web applications and designing complex test automation frameworks using Java / JEE technologies. Passionate about open-source automation frameworks that provide application modeling, unit, integration, functional, and visual testing. Contact me at linkedin.com/in/hima-bindu-peteti-378152a4
  3. 3. Agenda BDD in the context of test automation 01 Selenium Vs Selenide02 Selenide deep dive 03 04 05 06 Additional Selenide benefits Compare coding in Selenium and Selenide Design Patterns Fannie Mae Confidential and Proprietary 3
  4. 4. Bridging the gap between Business and Technology Fannie Mae Confidential and Proprietary 4 Business Technology
  5. 5. BDD in the context of Test Automation Features Examples Executable Specification’s Low level Specifications Business Goals Automate Examples using tools like Cucumber JBEHAVE Specflow You can use Conventional UNIT testing or dedicated BDD for this These specs are generated using a common language Fannie Mae Confidential and Proprietary 5 Build The Thing Right Build The right thing
  6. 6. BDD in the context of Test Automation SCENARIO Books can be added to the shopping cart Given my shopping cart is empty When I add the book “Harry Potter” to my shopping cart Then my shopping cart should contain 1 copy of “Harry Potter” SCENARIO Books can be removed from the shopping cart SCENARIO Shopping cart is initially empty SCENARIO The same book can be added multiple times to the shopping cart Manage books in shopping cart As a shop visitor… I want to collect books in my shopping cart… So that I can purchase multiple books at once… Feature Fannie Mae Confidential and Proprietary 6
  7. 7. Evolution of UI Automation 2004 2006 Since 2008 Since 2008 Protractor , Selenide, ng webdriver, Fluent Selenium Protractor, Selenide Simon Stewart at ThoughtWorks developed Selenium WebDriver Selenium WebDriver Jason Huggins - ThoughtWorks started Selenium RC and IDE Selenium RC Many add on's have been developed on top of Selenium WebDriver IO 1980’s Record and Play Automation tools Fannie Mae Confidential and Proprietary 7
  8. 8. Basic needs of UI automation Designed for Test automation Executes on multiple operating systems Multi browser execution Supports Multiple test framework s CICD and build tools integration Remote execution support Fannie Mae Confidential and Proprietary 8
  9. 9. Fannie Mae Confidential and Proprietary 9
  10. 10. Selenide Test Fannie Mae Confidential and Proprietary 10
  11. 11. Customization Fannie Mae Confidential and Proprietary 11
  12. 12. BDD With Selenide Fannie Mae Confidential and Proprietary 12 Writing Test Code that matters
  13. 13. Selenide Additional Benefits 13 Solves the problem of time out issues No more Stale Exceptions Inbuilt evidence capturing mechanism Inbuilt validation mechanism Additional UI locators Reduces the need of adding lot of third party libraries Concise API Reduces the need of writing Boiler plate code Fannie Mae Confidential and Proprietary open("https://saucecon.co m/"); $(byText("AGENDA")).clic k(); $(byText("ABOUT")).shou ldBe(Condition.visible)
  14. 14. Additional Selectors Fannie Mae Confidential and Proprietary 14 import static com.codeborne.selenide.Selectors.*;
  15. 15. Parent / Child Selectors Fannie Mae Confidential and Proprietary 15 Find data in a table row by content
  16. 16. jQuery Sizzle Selectors $$(":input").shouldBe(CollectionCondition.sizeGreaterThan(3)); $("input:first").shouldBe(Condition.readonly); $("input:nth(1)").shouldNotHave(Condition.enabled); Fannie Mae Confidential and Proprietary 16
  17. 17. Angular libraries Fannie Mae Confidential and Proprietary 17
  18. 18. Angular Support Fannie Mae Confidential and Proprietary 18 $(ByAngular.buttonText("Customer Login")).click(); $(ByAngular.cssContainingText("#CSSSelector","ExpectedText")). getSelectedOptions(); $(ByAngular.exactRepeater("ngrepeater")).data("RepeaterData"). contentEquals("Expected Data"); $(ByAngular.model(("ng-model")).cssSelector("CSS Selector").linkText("Select Angular")).shouldNotBe(Condition.empty);
  19. 19. Custom Matchers Fannie Mae Confidential and Proprietary 19
  20. 20. Radio Buttons Traditional Style: for(webElement radio: driver.findElement (By.name(“Admin Role”))) { if(“Admin Role”.equals(radio.getAttribute(“value”))) { radio.click(); } } throw new NoSuchElementException(“Radio field has no value); Selenide Way: selectRadio(By.name(“role”),”Admin Role”); Fannie Mae Confidential and Proprietary 20
  21. 21. List Boxes Traditional Style List<WebElement> fields = previewPricePage.getAllTableFields(); for(int i = 0; i < fields.size(); i++) { if(fields.get(i).getText().matches("[0-9.]+")) break; else{ if(fields.get(i).getText().equals(col1)) Assert.assertEquals(col2,fields.get(i+1).getText()); } } Selenide List Box: $(“By.id”).shouldHave(“Expected Text”); Fannie Mae Confidential and Proprietary 21
  22. 22. Alert Boxes Traditional Style: try { driver.switchTo().alert().accept(); driver.switchTo().defaultContent(); } catch (Exception e) { e.printStackTrace(); } Selenide: confirm(“Are you sure to delete your profile”); dismiss(“Text on the dismiss box”); Fannie Mae Confidential and Proprietary 22
  23. 23. More Functions Fannie Mae Confidential and Proprietary 23 Function Function $(“div”).scrollTo(); $(“div”).innerText(); $(“div”).innerHtml(); $(“div”).exists(); $(“select”).isImage(); $(“select”).getSelectedText(); $(“select”).getSelectedValue(); $(“div”).doubleClick(); $(“div”).contextClick(); $(“div”).hover(); $(“div”).dragAndDrop(); Zoom(2.5);
  24. 24. Selenide Collections $$ returns collection of elements $$(“.error”).shouldHave(size(3)); $$(":input").shouldBe(CollectionCondition.sizeGreaterThan(3)); $$(“#employees tbody tr”).shouldNotHave(texts (“Employee” , “ID : 222” “Admin_Role”)); $$(“#employees tbody tr”).filter(visible).shouldHave(size(4)); Fannie Mae Confidential and Proprietary 24
  25. 25. Selenide Collections $$(By.xpath("XPATH")).shouldHaveSize(1); (Verifies size) $$(By.xpath("")).shouldHave(CollectionCondition.texts("Expected Text")); $$(".element").shouldHave(sizeLessThan(13)); $$(".element").shouldHave(sizeGreaterThan(11)); $$(".element").shouldHave(sizeGreaterThanOrEqual(12)); $$(".element").shouldHave(sizeNotEqual(42)); Fannie Mae Confidential and Proprietary 25
  26. 26. File Downloads Fannie Mae Confidential and Proprietary 26
  27. 27. Compare Files Fannie Mae Confidential and Proprietary 27
  28. 28. File Operations Fannie Mae Confidential and Proprietary 28 $(".btn#cv").download().compareTo(ExpectedFile); ü loanDetails_PDF.getParentFile(); ü loanDetails_PDF.isDirectory(); ü loanDetails_PDF.length(); ü loanDetails_PDF.getPath(); ü loanDetails_PDF.canRead(); ü loanDetails_PDF.canWrite(); ü loanDetails_PDF.canExecute(); ü File.createTempFile("prefix", "suffix");
  29. 29. File Operations Fannie Mae Confidential and Proprietary 29 sellerDetails = $(".btn#cv").uploadFile(uploadFile); $(".btn#cv").uploadFile(new File("CV1.doc"), new File("CV2.doc"), new File("CV3.doc")); $(".btn#cv").uploadFromClasspath(fileName);
  30. 30. Page Object Design Pattern Actual Test Class Fannie Mae Confidential and Proprietary 30
  31. 31. Classic Page Objects Fannie Mae Confidential and Proprietary 31
  32. 32. Fannie Mae Confidential and Proprietary 32
  33. 33. Fannie Mae Confidential and Proprietary 33
  34. 34. Return On Investment End to End Test Integration Test Unit Tests Manual Checking Exploratory UI Based Workflow Tests API/ Service Layer Business Rules/ Functional Tests Unit Tests/ Component Tests 80-90% 5-15% 0-5% 5-10% 20-30% 80-85% Traditional TDD and BDD Fannie Mae Confidential and Proprietary 34
  35. 35. Return On Investment 40% Reduction in coding effort Concise API With Selenide’s Concise API your coding effort is reduced by 40% or more depending on the application under test, thereby improves maintainability. 30% Increase in script reliability As Selenide is built for the purpose of test automation, it supports lot of additional application specific locators which increases reliability of your executions. Fannie Mae Confidential and Proprietary 35
  36. 36. Resources Fannie Mae Confidential and Proprietary 36 Selenide Articles: Selenide CheatSheet: https://gist.github.com/mkpythonanywhereblog/947633ba1bf0bc239639 Selenide Official site: https://selenide.org/quick-start.html Selenide JavaDoc: https://selenide.org/javadoc/current/ https://zeroturnaround.com/rebellabs/if-you-use-selenium-for-browser-based-ui-acceptance-testing-you-might-like- selenide/ Selenide Code reference: Selenide Git Repo: https://github.com/selenide/selenide Selenide Change Log: https://github.com/selenide/selenide/blob/master/CHANGELOG.md Selenide Example projects: https://github.com/selenide-examples
  37. 37. Fannie Mae Confidential and Proprietary BDD With Selenide is all about Writing Software that not only works but matters. Hima Bindu Peteti linkedin.com/in/hima-bindu-peteti-378152a4

×