Start of My WATIR Journey and Problems Along the Way @Bgrgincic and the Journey Starts…

Start of My WATIR Journey and Problems Along the Way @Bgrgincic and the Journey Starts…

Start of my WATIR journey and problems along the way @bgrgincic And the journey starts… Goal: ◦ Automate GWT aplication regression tests Options? ◦ Selenium? ⚫ Selenium IDE? ⚫ Selenium in Java? ◦ Watir (Web aplication testing in Ruby)? ◦ Something else? Let’s try Watir! How to start? => https://leanpub.com/watirbook Selenium-webdriver Lost in xpaths require "selenium-webdriver" b = Selenium::WebDriver.for :chrome … wait.until { b.find_element(:xpath, "//html/body/div[3]/div[2]/div/div/div[7]/table/tbody/tr[1]/td/table/tbody/tr[31] /td/table/tbody/tr[2]/td[2]/div") } b.find_element(:xpath, "//html/body/div[3]/div[2]/div/div/div[7]/table/tbody/tr[1]/td/table/tbody/tr[32]/td/table/tbody/tr [2]/td[2]/div/table/tbody/tr[1]/td/button/span").click p "Odabir razdoblja " b.find_element(:xpath, "//html/body/div[3]/div[2]/div/div/div[9]/div/div/table/tbody/tr/td/table/tbody/tr[1] /td/div/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td/table/tbody/tr[1]/td[2]/table/tbody/tr/td/select").send_keys(„NAZIV") b.find_element(:xpath, "//html/body/div[3]/div[2]/div/div/div[9]/div/div/table/tbody/tr/td/table/tbody/tr[1] /td/div/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td/table/tbody/tr[2]/td[2]/table/tbody/tr/td/select").send_keys("7") b.find_element(:xpath, "//html/body/div[3]/div[2]/div/div/div[9]/div/div/table/tbody/tr/td/table/tbody/tr[1] /td/div/table/tbody/tr[2]/td/div/table/tbody/tr[1]/td/table/tbody/tr[2]/td[3]/table/tbody/tr/td/select").send_keys("2013") b.find_element(:id, "button_btnTrazi_search").click b.find_element(:id, "button_btnOdaberi_select_calculation").click Watir-webdriver This seems like a nice API require "watir" b = Watir::Browser.new :chrome … b.span(:text, "Otvaranje").click b.select_list(:title, "Institucija").wait_until_present b.select_list(:title, "Institucija").select „Naziv" b.select_lists(:class, "spray-ComboBox spray-RequiredField spray-fld_plain")[1].click b.select_lists(:class, "spray-ComboBox spray-RequiredField spray-fld_plain")[1].select '7' b.select_lists(:class, "spray-ComboBox spray-RequiredField spray-fld_plain")[2].click b.select_lists(:class, "spray-ComboBox spray-RequiredField spray-fld_plain")[2].select "2013" b.button(:id, "button_btnTrazi_search").click b.button(:id, "button_btnOdaberi_select_calculation").click What seemed nice with Watir-webdriver API? Many different ways to access the elements ◦ :class, :css, :for, :href, :id, :index, :name, :src, :text, :value, : xpath Cool verification actions ◦ .exists?, .visible?, enabled?, present?, etc. Nice support for waits (good for ajax rich apps) And the problems begin… click of null- what?? 1/2 HTML: <button type="button" id="button_btnTrazi_search" title="Traži"><span >Traži</span></button> Watir test: b.button(:id, "button_btnTrazi_search").click click of null- what?? 2/2 Just close the console! No problems afterwards The Devil’s in the details 1/2 Get select by class name The Devil’s in the details 2/2 Tip: click on a ‘select’ before ‘selecting’ <div> of death 1/2 „loading” <div> <div> of death 2/2 Solution #1: put check before every command? Solution #2: define a „proxy” Quick final thoughts Ruby is pretty fun and easy ◦ You can start using Watir without knowing much about Ruby Cheatsheets are useful ◦ https://github.com/watir/watir/wiki/Cheat-Sheet ◦ https://github.com/watir/watir/wiki/Cheat-Sheet-for-Ruby ◦ http://relevantcodes.com/watir-webdriver-cheat-sheet/ There’s also useful stuff on ◦ http://stackoverflow.com ◦ http://watirmelon.com/ ◦ http://filipin.eu/ The future? Find a cool IDE instead of Notepad++ Get a Watir recorder? Do I need Cucumber (behavior-driven development)? Use advanced patterns: page objects etc..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    14 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us