SlideShare une entreprise Scribd logo
1  sur  44
Watir Study ---In the view as a tester


  1. Watir Introduction.
  2. Why Watir?
  3. Install Ruby and Watir.
  4. Study Ruby and locate elements
  5. Watir & Ruby Resources


07/01/09
Watir introduction.

1.  W A                T
         eb pplication esting n I R     uby
2. It is a Ruby library which drives Internet Explorer the
     same way people do, clicks links, fills in forms, and
     presses buttons.
3. Watir also checks results, such as whether
     expected text appears on the page.
4. Because it’s build on Ruby, you have the power to
     connect to databases, read data files, export
     XML, excel and structure your code into reusable
     libraries.


07/01/09
Why Watir?
• Open-source
• Powerful, due to Ruby is powerful.
• Simple (easy to use and learn)
• Excellent Support , there’s a very
  active and growing community behind
  it.
• Support many browsers such as IE,
  Firefox, Safari, Google chrome, Opera
07/01/09
About Watir automation
•      For automation, the most important is: to do the
       repeated work, so Watir can.
•      Even if you won’t go on a complete automation
       test, you can use Watir to improve your work
       efficiency in your manual black-box test.
•      It is easy to build up the whole frame for your
       project, because define the object, module, class
       in ruby is agile, but if you want to study it quite
       well, you have to study a lot.



07/01/09
How to improve your work
             efficiency in Watir?
• Two examples.




07/01/09
Example 1: How to test issue like
    train-3401? Turn to train-3401
• Run train-3401.rb
• For some work, when use Watir, we can
  improve the work efficiency easily




07/01/09
Example 2: How to test the issue like
            train-3374?
• Turn to train-3374 and tpSearch.do page
• Run train-3374_84.rb;
• For some work, it is really difficult to do
  manual, but easy when use Watir




07/01/09
Watir automation frame
1.     It is with clear structure;
2.     It is easy to manage, maintain the code
3.     The code is easy to read.
4.     The code can be reused;




07/01/09
A Watir Frame




07/01/09
The frame
•   Element: Store all the frequently-used elements, once the elements on
    the page have been changed, we just need fix it at one place;
•   DataFile: For the automation, we’d better prepare test data, we may
    store all the data in an excel file, this class may get the corresponding
    test data from the excel;
•   StdLib: it deal with the logic in our project, make an example: on edit
    something page, we make some calculation, after save it, it display
    another result, in our automation, we have to check the calculation is
    right or not, so we have to include the arithmetic in a function in file
    StdLib;
•   Reporting: it stores test_passed, test_failed methods, create the test
    result.
•   CreateAccountTC, CustomizeWebTC are all test cases, we will run
    them one by one in the Regression




07/01/09
How to make the frame fit for your
             project?
1. What are the relationships between the
   different models? Any common attributes?
   Completely different?
2. How to make the frame easy to understood to
   you?
3. If the requirement changes, do you have to
   change a lot for replay the script?
4. When you know one frame clearly, you may
   know other frame easy



07/01/09
Frame of Commerce team




07/01/09
What’s our goal?
1. Prepare a test data file;
2. Run our automation script following our
  frame;
3. Get a detailed bug report file, easy to
  know where the bug is.




07/01/09
Test data file




07/01/09
Report file




07/01/09
How to achieve the goal?
•   1. Study function  For Element
•   2. Study class and modules For Stdlib
•   3. Read from the file  For DataFile
•   4. Output to a file  For Reporting
•   5. Understand Watir test frame  For
    CreateAccountTC



07/01/09
Install
1. Install Ruby-1.8.6
2. Install Watir
     1) go to command window
    2) gem update --system
    3) gem install Watir
3. Install Ruby IDE, such as Netbeans.
4. Install IE developer toolbar, FireBug




07/01/09
What you need to do if you want
              automation?
•   Navigate the browser
•   Find elements on the page
•   Interact with elements on the page
•   Check output on the page
      – Create and use Methods
      – Create formal test cases
      – Get the report file



07/01/09
How to turn to an IE browser?
1. Create a new IE window
2. Attach to an existing IE window;




07/01/09
Create a new IE browser
• $ie=Watir::IE.new
  $ie.goto(www.active.com)
• $ie=Watir::IE.start(www.active.com)




07/01/09
Attach to an existing browser
• $ie=Watir::IE.attach(:title, ‘’)
• $ie=Watir::IE.attach(:url, ‘’)
• $ie=Watir::IE.find(:title, ‘’)




07/01/09
How to interact with the web
                    element?
•   require 'watir'
•   $ie=Watir::IE.attach(:title, /Google/)
•   $ie.bring_to_front
•   $ie.maximize
•   $ie.text_field(:name, "q").set("google")
•   $ie.button(:value, "I'm Feeling Lucky").click
•   #$ie.button(:name,"btnI").click



07/01/09
Finding <HTML> Elements
 TextBox             IE.text_field(how, what)
 Button              IE.button(how, what)
 DropDownList        IE.select_list(how, what)
 CheckBox            IE.checkbox(how, what)
 RadioButton         IE.radio(how, what)
 HyperLink           IE.link(how, what)
 Form                IE.form(how, what)
 Frame               IE.frame(how, what)
 And many, many more (div, label, image, etc…)…
 Provides different ways to access objects.

07/01/09
What’s ‘how’ and ‘what’?
For IE.text_field(:how, what)
1. IE: means the ie6, ie7 or ie8 window
2. how: means the attributes used to define the
  text_field, such as id, name and so on
3. what: the value of the attributes in step 2.
4. Example: ie.text_field(:name, "q") defines the
  text box with name of ‘q’ in an opened ie window




07/01/09
Some How and what?




07/01/09
Check output on the page
• # Check whether we can get the search result
• if $ie.text.include?("google earth")
•     puts "We can get the search result as expected"
•      #$report.test_passed("Get the search result as
  expected")
• else
•     puts "Failed to search the result we want"
•     #$report.test_failed("Failed to get the search result as
  expected")
• end



07/01/09
Define the ruby method in class
                and module
•   require 'watir‘
•   #If you put class TestA into another .rb file, you just need:
•   #require “filepath/filename.rb”, then you can use the class the same as below, so do the module.
•   class TestA
•      def test_a(str)
•         puts str
•      end
•   end

•   module TestB
•     def test_a(str)
•       puts str
•     end
•   end

•   testa=TestA.new
•   testa.test_a("Hello World 1")
•   include TestB
•   test_a("Hello World 2")




07/01/09
How to use module and class?

In Ruby, only single inheritance allowed.
Football.rb
3. Football is with Round attributes
4. Football is with Elastomer attributes;
An example of football class, with both Round attributes
    and Elastomer




07/01/09
Create a google search test case




07/01/09
Create Methods
•   require 'watir'

•   # It is kind of Element file
•   def search_field
•      return $ie.text_field(:name, "q")
•   end
•   def lucky_search_button
•      return $ie.button(:value, "I'm Feeling Lucky")
•   end

•   # It is kind of StdLib file
•   def get_all_links_with_google_word
•      google_word_links=[]
•      $ie.links.select { |link|
•          if link.text.downcase.include?("google")
•               google_word_links << link.text
•          end
•      }
•      return google_word_links
•   end




07/01/09
Use Methods
•   # Open an new ie window
•   $ie=Watir::IE.start("www.google.com")
•   $ie.bring_to_front
•   $ie.maximize

•   # Set the content we want to search in google.
•   search_field.set("google")
•   lucky_search_button.click

•   # Check whether we can get the search result
•   puts get_all_links_with_google_word
•   if get_all_links_with_google_word.include?("google map")
•       puts “Passed: There is google map after the search"
•   else
•       puts “Failed: No google map link after the search"
•   end


07/01/09
Create formal test cases
 •   require 'watir'
 •   require 'watir/testcase'
 •   class TestGoogle < Watir::TestCase
 •      def test_setup
 •        $ie=Watir::IE.new
 •        $ie.goto("www.google.com")
 •        $ie.bring_to_front
 •        $ie.maximize
 •      end
 •      def test_turn_to_google_search_page
 •        assert $ie.title.eql?("Google"), "Open IE as expected"
 •        assert $ie.button(:name,/btnG/).exists?, "Search button is existing"
 •        assert $ie.link(:text,"privacy").exists?, "No link privacy"
 •      end
 •      def test_search
 •        $ie.text_field(:name,"q").set("Google")
 •        $ie.button(:name,"btnI").click
 •        assert $ie.text.include?("google earth"), "Search as expected"
 •      end
 •   end



07/01/09
Practice file
•   Read write text file
•   Read write PDF
•   Read write Excel
•   Read SQL file




07/01/09
Text example
•      require 'watir'
•      # Create a text file, put something into it;
•      file=File.new("c:test.txt","w")
•      for i in 0..50
•          file.puts "Now, write #{i}"
•      end
•      file.close
•      system("start c:test.txt")
•      sleep 5
•      system("TASKKILL /F /IM notepad.exe")

•      #Read the content out from the file
•      file2=File.open("c:test.txt","r")
•      while f=file2.gets()
•          puts "Now, read:" + f
•      end
•      file2.close

•      system("del c:test.txt")




07/01/09
PDF file
1.     Gem install pdf-writer
2.     Put pdftotext.exe into c:windowssystem32
•      require "pdf/writer"
•      pdf = PDF::Writer.new
•      pdf.select_font "Times-Roman"
•      pdf.text "Hello, Ruby.", :font_size => 72, :justification => :center
•      for i in 0..10
•         pdf.text "Nice #{i}n", :font_size =>16, :justification => :left
•      end
•      pdf.save_as("c:hello.pdf")
•      pdf.close

•      system("start c:hello.pdf")
•      sleep 5
•      system("TASKKILL /F /IM Acrord32.exe")

•      system("pdftotext -layout -q c:hello.pdf c:test.txt")
•      sleep 1

•      system("start c:test.txt")
•      sleep 3

•      system("TASKKILL /F /IM notepad.exe")
•      system("del c:test.txt")
•      system("del c:hello.pdf")




07/01/09
Excel
•      require 'win32ole'
•      # Write some data to an excel file
•      excel = WIN32OLE.new("excel.application")
•      excel.visible = true
•      workbook = excel.workbooks.add
•      worksheet = workbook.Worksheets(1)
•      worksheet.Range("a1").value = 3
•      worksheet.Range("a2").value = 2
•      worksheet.Range("a3:c10").value = 1
•      workbook.saveas("c:test.xls")

•      # Read data from the excel file
•      sleep 3
•      workbook = excel.workbooks.open("c:test.xls")
•      worksheet=workbook.worksheets(1)

•      first_column=[]
•      row=1
•      while worksheet.range("a#{row}").value
•          first_column << worksheet.range("a#{row}").value
•          row += 1
•      end
•      workbook.close
•      excel.quit
•      p first_column

•      system("del c:test.xls")




07/01/09
Read data from SQL server
• Talk about sql-server.rb




07/01/09
How to make the watir system
                methods to yours
1. Turn to assert, verify system class or module;
2. Copy the modules or class out;
3. Make any changes on the methods or class as
  you want
4. First: require the file name include system
  module or class
5. Second: require your file name
6. Your method will cover the system method, so it
  responses as you want.
7. Once you want to use system method again,
  you just need quite the require in step 5

07/01/09
Example: rewrite Watir inner Verify
             method
• rewrite_verify.rb




07/01/09
Change .rb file into .exe
• gem install rubyscript2exe
• Rubyscript2exe script.rb




07/01/09
Clear idea about this Frame now?




07/01/09
Watir Limitation
•      Doesn’t test Flash or Applets.(underwork)
•      Can’t practice on Google map, drag mouse.
•      Deal with pop ups, frame not sensitive
       enough, We can deal with it by sleep
•      The display of web pages will be affected by
       the computer performance, network speed,
       and Watir drives the browsers, so it will also
       be impacted by the two factors.


07/01/09
Watir & Ruby Resources
Watir
• Watir main site: http://wiki.openqa.org/display/WTR/
• Watir user guide: wtr.rubyforge.org/watir_user_guide.html
• Watir API: wtr.rubyforge.org/rdoc/index.html
• Mailing List: rubyforge.org/mailman/listinfo/wtr-general
• Project site: http://wiki.openqa.org/display/WTR/
• User Contributions/examples: http://wiki.openqa.org/display/WTR/Contributions
• Watir FAQ: http://wiki.openqa.org/display/WTR/FAQ

•   Ruby
•   Ruby site: http://ruby-lang.org
•   Ruby docs: http://ruby-doc.org/
•   Ruby Quickstart: ruby-lang.org/en/documentation/quickstart/

•   A great group, really helpful: http://groups.google.com/group/watir-general




07/01/09
Questions && discussion




      Any questions or ideas, please contact MSN: cjq_999@sina.com



07/01/09

Contenu connexe

Tendances

Selenium Automation Using Ruby
Selenium Automation Using RubySelenium Automation Using Ruby
Selenium Automation Using RubyKumari Warsha Goel
 
jQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksAddy Osmani
 
Selenium webdriver
Selenium webdriverSelenium webdriver
Selenium webdriversean_todd
 
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...Rashedul Islam
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...Ho Chi Minh City Software Testing Club
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress PluginAndy Stratton
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introductionTomi Juhola
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behatimoneytech
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testingdrewz lin
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
Apache Ant
Apache AntApache Ant
Apache AntAli Bahu
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with CucumberBrandon Keepers
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With CucumberSean Cribbs
 

Tendances (20)

Selenium Automation Using Ruby
Selenium Automation Using RubySelenium Automation Using Ruby
Selenium Automation Using Ruby
 
jQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & Tricks
 
Selenium bootcamp slides
Selenium bootcamp slides   Selenium bootcamp slides
Selenium bootcamp slides
 
Web driver training
Web driver trainingWeb driver training
Web driver training
 
Django Heresies
Django HeresiesDjango Heresies
Django Heresies
 
Selenium webdriver
Selenium webdriverSelenium webdriver
Selenium webdriver
 
Page object pattern
Page object patternPage object pattern
Page object pattern
 
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
Step 8_7_ 6_5_4_3_2_ 1 in one_Tutorial for Begineer on Selenium Web Driver-Te...
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
BDD with cucumber
BDD with cucumberBDD with cucumber
BDD with cucumber
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Apache Ant
Apache AntApache Ant
Apache Ant
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
 
Django Girls Tutorial
Django Girls TutorialDjango Girls Tutorial
Django Girls Tutorial
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
 

Similaire à What you can do In WatiR

Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Roy de Kleijn
 
Advanced Site Studio Class, June 18, 2012
Advanced Site Studio Class, June 18, 2012Advanced Site Studio Class, June 18, 2012
Advanced Site Studio Class, June 18, 2012Lee Klement
 
SPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have knownSPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have knownMark Rackley
 
Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Applitools
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium SuccessfullyDave Haeffner
 
Automated testing in javascript
Automated testing in javascriptAutomated testing in javascript
Automated testing in javascriptMichael Yagudaev
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with SeleniumDave Haeffner
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery EssentialsMark Rackley
 
Android webinar class_5
Android webinar class_5Android webinar class_5
Android webinar class_5Edureka!
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfullyTEST Huddle
 
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.WO Community
 
Java EE Revisits Design Patterns
Java EE Revisits Design PatternsJava EE Revisits Design Patterns
Java EE Revisits Design PatternsAlex Theedom
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)Sauce Labs
 
Beyond Domino Designer
Beyond Domino DesignerBeyond Domino Designer
Beyond Domino DesignerPaul Withers
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsLuís Bastião Silva
 
John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)Jia Mi
 
Java EE revisits design patterns
Java EE revisits design patternsJava EE revisits design patterns
Java EE revisits design patternsAlex Theedom
 
Untangling spring week5
Untangling spring week5Untangling spring week5
Untangling spring week5Derek Jacoby
 

Similaire à What you can do In WatiR (20)

Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
 
Advanced Site Studio Class, June 18, 2012
Advanced Site Studio Class, June 18, 2012Advanced Site Studio Class, June 18, 2012
Advanced Site Studio Class, June 18, 2012
 
SPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have knownSPSDenver - SharePoint & jQuery - What I wish I would have known
SPSDenver - SharePoint & jQuery - What I wish I would have known
 
Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Automated testing in javascript
Automated testing in javascriptAutomated testing in javascript
Automated testing in javascript
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
 
Android webinar class_5
Android webinar class_5Android webinar class_5
Android webinar class_5
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfully
 
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
Beyond Fluffy Bunny. How I leveraged WebObjects in my lean startup.
 
Java EE Revisits Design Patterns
Java EE Revisits Design PatternsJava EE Revisits Design Patterns
Java EE Revisits Design Patterns
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Database training for developers
Database training for developersDatabase training for developers
Database training for developers
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)
 
Beyond Domino Designer
Beyond Domino DesignerBeyond Domino Designer
Beyond Domino Designer
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
 
John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)John Resig Beijing 2010 (English Version)
John Resig Beijing 2010 (English Version)
 
Java EE revisits design patterns
Java EE revisits design patternsJava EE revisits design patterns
Java EE revisits design patterns
 
Untangling spring week5
Untangling spring week5Untangling spring week5
Untangling spring week5
 

Dernier

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Dernier (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

What you can do In WatiR

  • 1. Watir Study ---In the view as a tester 1. Watir Introduction. 2. Why Watir? 3. Install Ruby and Watir. 4. Study Ruby and locate elements 5. Watir & Ruby Resources 07/01/09
  • 2. Watir introduction. 1. W A T eb pplication esting n I R uby 2. It is a Ruby library which drives Internet Explorer the same way people do, clicks links, fills in forms, and presses buttons. 3. Watir also checks results, such as whether expected text appears on the page. 4. Because it’s build on Ruby, you have the power to connect to databases, read data files, export XML, excel and structure your code into reusable libraries. 07/01/09
  • 3. Why Watir? • Open-source • Powerful, due to Ruby is powerful. • Simple (easy to use and learn) • Excellent Support , there’s a very active and growing community behind it. • Support many browsers such as IE, Firefox, Safari, Google chrome, Opera 07/01/09
  • 4. About Watir automation • For automation, the most important is: to do the repeated work, so Watir can. • Even if you won’t go on a complete automation test, you can use Watir to improve your work efficiency in your manual black-box test. • It is easy to build up the whole frame for your project, because define the object, module, class in ruby is agile, but if you want to study it quite well, you have to study a lot. 07/01/09
  • 5. How to improve your work efficiency in Watir? • Two examples. 07/01/09
  • 6. Example 1: How to test issue like train-3401? Turn to train-3401 • Run train-3401.rb • For some work, when use Watir, we can improve the work efficiency easily 07/01/09
  • 7. Example 2: How to test the issue like train-3374? • Turn to train-3374 and tpSearch.do page • Run train-3374_84.rb; • For some work, it is really difficult to do manual, but easy when use Watir 07/01/09
  • 8. Watir automation frame 1. It is with clear structure; 2. It is easy to manage, maintain the code 3. The code is easy to read. 4. The code can be reused; 07/01/09
  • 10. The frame • Element: Store all the frequently-used elements, once the elements on the page have been changed, we just need fix it at one place; • DataFile: For the automation, we’d better prepare test data, we may store all the data in an excel file, this class may get the corresponding test data from the excel; • StdLib: it deal with the logic in our project, make an example: on edit something page, we make some calculation, after save it, it display another result, in our automation, we have to check the calculation is right or not, so we have to include the arithmetic in a function in file StdLib; • Reporting: it stores test_passed, test_failed methods, create the test result. • CreateAccountTC, CustomizeWebTC are all test cases, we will run them one by one in the Regression 07/01/09
  • 11. How to make the frame fit for your project? 1. What are the relationships between the different models? Any common attributes? Completely different? 2. How to make the frame easy to understood to you? 3. If the requirement changes, do you have to change a lot for replay the script? 4. When you know one frame clearly, you may know other frame easy 07/01/09
  • 12. Frame of Commerce team 07/01/09
  • 13. What’s our goal? 1. Prepare a test data file; 2. Run our automation script following our frame; 3. Get a detailed bug report file, easy to know where the bug is. 07/01/09
  • 16. How to achieve the goal? • 1. Study function  For Element • 2. Study class and modules For Stdlib • 3. Read from the file  For DataFile • 4. Output to a file  For Reporting • 5. Understand Watir test frame  For CreateAccountTC 07/01/09
  • 17. Install 1. Install Ruby-1.8.6 2. Install Watir 1) go to command window 2) gem update --system 3) gem install Watir 3. Install Ruby IDE, such as Netbeans. 4. Install IE developer toolbar, FireBug 07/01/09
  • 18. What you need to do if you want automation? • Navigate the browser • Find elements on the page • Interact with elements on the page • Check output on the page – Create and use Methods – Create formal test cases – Get the report file 07/01/09
  • 19. How to turn to an IE browser? 1. Create a new IE window 2. Attach to an existing IE window; 07/01/09
  • 20. Create a new IE browser • $ie=Watir::IE.new $ie.goto(www.active.com) • $ie=Watir::IE.start(www.active.com) 07/01/09
  • 21. Attach to an existing browser • $ie=Watir::IE.attach(:title, ‘’) • $ie=Watir::IE.attach(:url, ‘’) • $ie=Watir::IE.find(:title, ‘’) 07/01/09
  • 22. How to interact with the web element? • require 'watir' • $ie=Watir::IE.attach(:title, /Google/) • $ie.bring_to_front • $ie.maximize • $ie.text_field(:name, "q").set("google") • $ie.button(:value, "I'm Feeling Lucky").click • #$ie.button(:name,"btnI").click 07/01/09
  • 23. Finding <HTML> Elements TextBox IE.text_field(how, what) Button IE.button(how, what) DropDownList IE.select_list(how, what) CheckBox IE.checkbox(how, what) RadioButton IE.radio(how, what) HyperLink IE.link(how, what) Form IE.form(how, what) Frame IE.frame(how, what) And many, many more (div, label, image, etc…)… Provides different ways to access objects. 07/01/09
  • 24. What’s ‘how’ and ‘what’? For IE.text_field(:how, what) 1. IE: means the ie6, ie7 or ie8 window 2. how: means the attributes used to define the text_field, such as id, name and so on 3. what: the value of the attributes in step 2. 4. Example: ie.text_field(:name, "q") defines the text box with name of ‘q’ in an opened ie window 07/01/09
  • 25. Some How and what? 07/01/09
  • 26. Check output on the page • # Check whether we can get the search result • if $ie.text.include?("google earth") • puts "We can get the search result as expected" • #$report.test_passed("Get the search result as expected") • else • puts "Failed to search the result we want" • #$report.test_failed("Failed to get the search result as expected") • end 07/01/09
  • 27. Define the ruby method in class and module • require 'watir‘ • #If you put class TestA into another .rb file, you just need: • #require “filepath/filename.rb”, then you can use the class the same as below, so do the module. • class TestA • def test_a(str) • puts str • end • end • module TestB • def test_a(str) • puts str • end • end • testa=TestA.new • testa.test_a("Hello World 1") • include TestB • test_a("Hello World 2") 07/01/09
  • 28. How to use module and class? In Ruby, only single inheritance allowed. Football.rb 3. Football is with Round attributes 4. Football is with Elastomer attributes; An example of football class, with both Round attributes and Elastomer 07/01/09
  • 29. Create a google search test case 07/01/09
  • 30. Create Methods • require 'watir' • # It is kind of Element file • def search_field • return $ie.text_field(:name, "q") • end • def lucky_search_button • return $ie.button(:value, "I'm Feeling Lucky") • end • # It is kind of StdLib file • def get_all_links_with_google_word • google_word_links=[] • $ie.links.select { |link| • if link.text.downcase.include?("google") • google_word_links << link.text • end • } • return google_word_links • end 07/01/09
  • 31. Use Methods • # Open an new ie window • $ie=Watir::IE.start("www.google.com") • $ie.bring_to_front • $ie.maximize • # Set the content we want to search in google. • search_field.set("google") • lucky_search_button.click • # Check whether we can get the search result • puts get_all_links_with_google_word • if get_all_links_with_google_word.include?("google map") • puts “Passed: There is google map after the search" • else • puts “Failed: No google map link after the search" • end 07/01/09
  • 32. Create formal test cases • require 'watir' • require 'watir/testcase' • class TestGoogle < Watir::TestCase • def test_setup • $ie=Watir::IE.new • $ie.goto("www.google.com") • $ie.bring_to_front • $ie.maximize • end • def test_turn_to_google_search_page • assert $ie.title.eql?("Google"), "Open IE as expected" • assert $ie.button(:name,/btnG/).exists?, "Search button is existing" • assert $ie.link(:text,"privacy").exists?, "No link privacy" • end • def test_search • $ie.text_field(:name,"q").set("Google") • $ie.button(:name,"btnI").click • assert $ie.text.include?("google earth"), "Search as expected" • end • end 07/01/09
  • 33. Practice file • Read write text file • Read write PDF • Read write Excel • Read SQL file 07/01/09
  • 34. Text example • require 'watir' • # Create a text file, put something into it; • file=File.new("c:test.txt","w") • for i in 0..50 • file.puts "Now, write #{i}" • end • file.close • system("start c:test.txt") • sleep 5 • system("TASKKILL /F /IM notepad.exe") • #Read the content out from the file • file2=File.open("c:test.txt","r") • while f=file2.gets() • puts "Now, read:" + f • end • file2.close • system("del c:test.txt") 07/01/09
  • 35. PDF file 1. Gem install pdf-writer 2. Put pdftotext.exe into c:windowssystem32 • require "pdf/writer" • pdf = PDF::Writer.new • pdf.select_font "Times-Roman" • pdf.text "Hello, Ruby.", :font_size => 72, :justification => :center • for i in 0..10 • pdf.text "Nice #{i}n", :font_size =>16, :justification => :left • end • pdf.save_as("c:hello.pdf") • pdf.close • system("start c:hello.pdf") • sleep 5 • system("TASKKILL /F /IM Acrord32.exe") • system("pdftotext -layout -q c:hello.pdf c:test.txt") • sleep 1 • system("start c:test.txt") • sleep 3 • system("TASKKILL /F /IM notepad.exe") • system("del c:test.txt") • system("del c:hello.pdf") 07/01/09
  • 36. Excel • require 'win32ole' • # Write some data to an excel file • excel = WIN32OLE.new("excel.application") • excel.visible = true • workbook = excel.workbooks.add • worksheet = workbook.Worksheets(1) • worksheet.Range("a1").value = 3 • worksheet.Range("a2").value = 2 • worksheet.Range("a3:c10").value = 1 • workbook.saveas("c:test.xls") • # Read data from the excel file • sleep 3 • workbook = excel.workbooks.open("c:test.xls") • worksheet=workbook.worksheets(1) • first_column=[] • row=1 • while worksheet.range("a#{row}").value • first_column << worksheet.range("a#{row}").value • row += 1 • end • workbook.close • excel.quit • p first_column • system("del c:test.xls") 07/01/09
  • 37. Read data from SQL server • Talk about sql-server.rb 07/01/09
  • 38. How to make the watir system methods to yours 1. Turn to assert, verify system class or module; 2. Copy the modules or class out; 3. Make any changes on the methods or class as you want 4. First: require the file name include system module or class 5. Second: require your file name 6. Your method will cover the system method, so it responses as you want. 7. Once you want to use system method again, you just need quite the require in step 5 07/01/09
  • 39. Example: rewrite Watir inner Verify method • rewrite_verify.rb 07/01/09
  • 40. Change .rb file into .exe • gem install rubyscript2exe • Rubyscript2exe script.rb 07/01/09
  • 41. Clear idea about this Frame now? 07/01/09
  • 42. Watir Limitation • Doesn’t test Flash or Applets.(underwork) • Can’t practice on Google map, drag mouse. • Deal with pop ups, frame not sensitive enough, We can deal with it by sleep • The display of web pages will be affected by the computer performance, network speed, and Watir drives the browsers, so it will also be impacted by the two factors. 07/01/09
  • 43. Watir & Ruby Resources Watir • Watir main site: http://wiki.openqa.org/display/WTR/ • Watir user guide: wtr.rubyforge.org/watir_user_guide.html • Watir API: wtr.rubyforge.org/rdoc/index.html • Mailing List: rubyforge.org/mailman/listinfo/wtr-general • Project site: http://wiki.openqa.org/display/WTR/ • User Contributions/examples: http://wiki.openqa.org/display/WTR/Contributions • Watir FAQ: http://wiki.openqa.org/display/WTR/FAQ • Ruby • Ruby site: http://ruby-lang.org • Ruby docs: http://ruby-doc.org/ • Ruby Quickstart: ruby-lang.org/en/documentation/quickstart/ • A great group, really helpful: http://groups.google.com/group/watir-general 07/01/09
  • 44. Questions && discussion Any questions or ideas, please contact MSN: cjq_999@sina.com 07/01/09