2. About me MykolaKolisnyk Overall experience: 6+ years Positions: QA Lead Senior Automation Consultant Test Automation Architect Tools:SilkTest TestComplete Selenium RFT SoapUI Co-author: “SilkTest manual” book (http://silktutorial.ru) Portal http://automated-testing.info
13. How about tests like that? Behavior description prior to implementation
14. List of BDD engines NBehave Cucumber Freshen JBehave Behat
15. BDD tests structure Background Feature Given Background When Scenario 1 Then Scenario Scenario 2 Given Scenario N When Then
16. Connections to code Text instruction WhenI log into the system as “login”/”password” Actual Code When/log into the system as “(.*)””(.*)”/do|login,password| app.login( login , password ) end Explicit Selenium calls class App def login( username , password ) # Some actions end end
17. BDD project structure Main working folder Keyword implementations Core library Initialization module Tests storage
25. Stages to framework migration Decompose code by details level Extract Selenium object and wrap it into global object Wrap each function with appropriate keyword Re-design existing tests
26. Framework decomposition We care what we do only We care where we are Business Functions level Pages level We care how to do it Explicit Selenium calls Explicit Selenium calls Core level
27. Framework re-organization to BDD Code layer Business Functions level Pages level Global Selenium Object Core level
28. Implementation layer BF level Pages level Core level Tests layer Framework re-organization to BDD When /click on “(.*)” element/ do |locator| selenium.click( locator ) end Code layer BF level Pages level When I click on “Test” element Core level Selenium selenium.click( locator );
29. Collect all resources Initialize shell Global Selenium Object Run instructions Finalize execution Generate report Selenium place selenium.start() Start Call Command Stop DefaultSelenium.new selenium.stop()
30. There’re still some questions How to avoid duplicates? How to locate elements? How to store values? How to use random data?
31. UI elements mapping. What for? Which way is more reliable and informative? When I click on “Search" link When I click on "//div[@id='some_div']/button[text()='Add']" button When I click on "Add" button on "Home Page" When I create “test.txt" file in “%USERPROFILE%” folder When I create “test.txt" file in “C:Temp” folder
32. Page Title Name Item Alias Locator UI elements mapping. How? Examples: Ini file XML file
33. UI Mapping. Trivial case Text instruction: When I click on the “Updates” link Actual code: selenium.click( “link=Updates” );
34. UI Mapping. Specific page Will look into this section Will take this locator When I click on the “Apply Button” on the “Links Page” Will click here: selenium.click(“links_apply_btn”) Explicit Selenium calls Similar elements on different pages
35. UI Mapping. Current page Will read current page title Will find section with matching header Will take this locator When I click on the “Apply Button” element Will click here: selenium.click(“links_apply_btn”) Explicit Selenium calls Similar elements on different pages
36. Different keywords can do the same things Examples: When /click on the “(.*)” link/ When /click on “(.*)” link/ When /click on (.*) link/ Main challenges
38. After that: Examples: When /click on the “(.*)” link/ #Valid as conforms the rules When /click on “(.*)” link/#Invalid. Violates Rule #1 Main challenges Rule #1: each field, element, page name should have “the” article
Тема данного доклада “Использование селениума в контексте Behavior-Driven Development” (далее BDD). В данном докладе больше речь вестись будет не столько о Selenium, сколько о подходе как таковом, а также о том, каким образом Selenium встраивается в решение построенное с использованием данного подхода. Selenium (точнее его клиентская часть, которой пользуются разработчики автотестов) представляет из себя библиотеку с набором функций. То есть сама по себе библиотека особого интереса не представляет, а важен контекст, в котором она используется. Вот на этот и ряд других моментов будет и сделан упор, когда речь будет вестись об использовании Selenium-а.
Так кто же участвует в автоматизации тестирования теперь? Вся команда. Все вместе и каждый по отдельности