├── commonwatir ├── lib │ └── watir.rb ├── Rakefile ├── commonwatir.gemspec └── README ├── watir.gif ├── watir ├── lib │ ├── watir │ │ ├── version.rb │ │ └── loader.rb │ └── watir.rb ├── Rakefile └── watir.gemspec ├── .gitignore ├── CHANGES.md ├── Rakefile ├── LICENSE └── README.md /commonwatir/lib/watir.rb: -------------------------------------------------------------------------------- 1 | require 'watir/loader' -------------------------------------------------------------------------------- /watir.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/watir/watir_meta/HEAD/watir.gif -------------------------------------------------------------------------------- /watir/lib/watir/version.rb: -------------------------------------------------------------------------------- 1 | module Watir 2 | BUNDLE_VERSION = '5.0.0' 3 | end 4 | -------------------------------------------------------------------------------- /watir/lib/watir.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('watir/loader', File.dirname(__FILE__)) 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | pkg/* 2 | *.gem 3 | .bundle 4 | coverage 5 | rdoc 6 | .yardoc 7 | Gemfile.lock 8 | .idea/* -------------------------------------------------------------------------------- /commonwatir/Rakefile: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift File.expand_path("../lib", __FILE__) 2 | 3 | require 'bundler' 4 | Bundler::GemHelper.install_tasks -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | 5.0.0 - 2013/10/05 2 | --- 3 | 4 | * Add support for watir-classic 4.0. 5 | * README improvements. 6 | 7 | 4.0.2 - 2012/10/31 8 | --- 9 | 10 | * Fix setting Watir driver via environment variable WATIR_DRIVER. 11 | 12 | 4.0.1 - 2012/10/21 13 | --- 14 | 15 | * Add support for Watir::Browser.start, Watir::Browser.attach and any other Watir::Browser methods. 16 | 17 | 4.0.0 - 2012/09/30 18 | --- 19 | 20 | * Initial release for the Watir meta-gem, which allows to load different drivers. 21 | Refer to the README for more information. 22 | -------------------------------------------------------------------------------- /commonwatir/commonwatir.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | $:.push File.expand_path("../lib", __FILE__) 3 | $:.push File.expand_path("../../watir/lib", __FILE__) 4 | require "watir/version" 5 | 6 | Gem::Specification.new do |s| 7 | s.name = "commonwatir" 8 | s.version = "4.0.0" 9 | s.platform = Gem::Platform::RUBY 10 | s.authors = ["Bret Pettichord"] 11 | s.email = ["bret@pettichord.com"] 12 | s.homepage = "http://github.com/watir/watir" 13 | s.summary = %q{Common library for Watir} 14 | s.description = %q{This library is included so older versions of commonwatir are not activated} 15 | s.rubyforge_project = "watir" 16 | s.files = %x{git ls-files}.split("\n") 17 | s.require_paths = ["lib"] 18 | end 19 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake/clean' 2 | CLEAN << FileList['pkg', '*.gem', 'commonwatir/**/*.gem', 'watir/**/*.gem'] 3 | 4 | task :default => :build 5 | 6 | desc "Build all the Watir gems" 7 | task :build => :clean do 8 | build_gems 9 | end 10 | 11 | desc "Release all the Watir gems" 12 | task :release => :build do 13 | release_gems 14 | end 15 | 16 | def build_gems 17 | Dir.chdir("commonwatir") { sh "rake build" } 18 | Dir.chdir("watir") { sh "rake build:all" } 19 | 20 | mkdir_p "pkg" unless File.exist?("pkg") 21 | gems = Dir['{commonwatir,watir}/**/*.gem'] 22 | gems.each {|gem| FileUtils.cp gem, 'pkg'} 23 | end 24 | 25 | def release_gems 26 | Dir.chdir("commonwatir") { sh "rake release" } 27 | Dir.chdir("watir") do 28 | Dir["pkg/*.gem"].each do |gem| 29 | sh "gem push #{gem}" 30 | end 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /watir/Rakefile: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift File.expand_path("../lib", __FILE__) 2 | 3 | require 'bundler' 4 | Bundler::GemHelper.install_tasks 5 | 6 | task :default => "build:all" 7 | 8 | namespace :build do 9 | desc "Build for Windows platform." 10 | task :win => :build do 11 | begin 12 | ENV["build_for_windows"] = "true" 13 | Rake::Task["build"].reenable 14 | Rake::Task["build"].invoke 15 | ensure 16 | ENV["build_for_windows"] = nil 17 | end 18 | end 19 | 20 | desc "Build for all platforms." 21 | task :all => [:build, "build:win"] 22 | end 23 | 24 | namespace :release do 25 | desc "Release for Windows platform." 26 | task :win => "build:win" do 27 | sh "gem push #{Dir["pkg/*mingw32.gem"].sort_by{|f| File.mtime(f)}.last}" 28 | end 29 | 30 | desc "Release for all platforms." 31 | task :all => [:release, "release:win"] 32 | end 33 | -------------------------------------------------------------------------------- /watir/watir.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | require "bundler" 3 | $:.push File.expand_path("../lib", __FILE__) 4 | require "watir/version" 5 | 6 | Gem::Specification.new do |s| 7 | s.name = "watir" 8 | s.version = Watir::BUNDLE_VERSION 9 | s.platform = Gem::Platform::RUBY 10 | s.authors = ["Bret Pettichord"] 11 | s.email = ["bret@pettichord.com"] 12 | s.homepage = "http://github.com/watir/watir" 13 | s.summary = %q{Watir} 14 | s.description = %q{Automated testing tool for web applications. By Testers. For Testers.} 15 | s.rubyforge_project = "watir" 16 | s.files = %x{git ls-files}.split("\n") 17 | s.require_paths = ["lib"] 18 | s.add_dependency "commonwatir", "~>4" 19 | s.add_dependency "watir-webdriver" 20 | 21 | if ENV["build_for_windows"] 22 | s.platform = Gem::Platform::MINGW 23 | s.add_dependency "watir-classic", "~> 4.0" 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /commonwatir/README: -------------------------------------------------------------------------------- 1 | You're probably wondering why this directory is here. If a user does not have 2 | a previous release of watir in their local gem repository, it doesn't really 3 | matter. If, however, they have a previous watir installation then we could 4 | get into an issue that would prevent this code from running. 5 | 6 | When you require 'watir', ruby looks through each directory to see if a 7 | lib/watir.rb exists *independent* of the name of the gem. Watir is a pretty 8 | old project and at the point it was supporting firefox, safari and ie, a new 9 | gem was created to handle common code. This was the commonwatir gem and it had 10 | a lib/watir.rb which would load watir (not from the watir gem). 11 | 12 | So now we're moving to watir being the gem with the lib/watir.rb and we want to 13 | retain the ability to require 'watir'. If a user has an old watir build then 14 | ruby will find the older commonwatir first and run it from 15 | commonwatir/lib/watir.rb instead of the new location watir/lib/watir.rb. That 16 | results in the older version of watir loading even though a newer gem is 17 | installed. 18 | 19 | To make sure this doesn't happen we release a new commonwatir gem with a higher 20 | version number so it gets picked up instead of the older version. The watir.rb 21 | in commonwatir just delegates to watir/loader.rb 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------- 2 | Copyright (c) 2012, Bret Pettichord 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name Bret Pettichord, nor the names of any 16 | other contributors to this software may be used to endorse or promote 17 | products derived from this software without specific prior written 18 | permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS 21 | IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR 24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 30 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------- 32 | (based on BSD Open Source License) 33 | -------------------------------------------------------------------------------- /watir/lib/watir/loader.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('version', File.dirname(__FILE__)) 2 | 3 | module Watir 4 | class Browser 5 | def initialize(browser=nil, *args) 6 | self.class.load_driver_for browser 7 | 8 | # execute just loaded driver's #initialize 9 | initialize browser.nil? && Watir.driver == :webdriver ? :firefox : browser, *args 10 | end 11 | 12 | class << self 13 | def start(url, browser=nil, *args) 14 | load_driver_for browser 15 | 16 | if Watir.driver == :webdriver 17 | start url, browser || :firefox, *args 18 | else 19 | start url 20 | end 21 | end 22 | 23 | def method_missing(name, *args, &block) 24 | Watir.load_driver 25 | return super unless respond_to? name 26 | send name, *args, &block 27 | end 28 | 29 | def load_driver_for(browser) 30 | if browser && browser.respond_to?(:to_sym) && browser.to_sym != :ie && Watir.driver == :classic 31 | Watir.driver = :webdriver 32 | end 33 | Watir.load_driver 34 | end 35 | 36 | end 37 | end 38 | 39 | class << self 40 | def load_driver 41 | require "watir-#{driver}" 42 | end 43 | 44 | def driver 45 | @driver || (ENV["WATIR_DRIVER"] && ENV["WATIR_DRIVER"].to_sym) || default_driver 46 | end 47 | 48 | def driver=(driver) 49 | allowed_drivers = %w[webdriver classic] 50 | unless allowed_drivers.map(&:to_sym).include?(driver.to_sym) 51 | raise "Supported drivers are #{allowed_drivers.join(", ")}." 52 | end 53 | @driver = driver 54 | end 55 | 56 | def default_driver 57 | if ENV['OS'] == 'Windows_NT' 58 | :classic 59 | else 60 | :webdriver 61 | end 62 | end 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Status 2 | This code is no longer being used, and this repository exists only as an archive. 3 | 4 | 5 | # Watir 6 | Watir, pronounced water, is an open-source (BSD) family of Ruby libraries for automating web browsers. 7 | It supports your app no matter what technology it is developed in. 8 | They support Internet Explorer on Windows, Firefox and Chrome on Windows, Mac and Linux. 9 | 10 | 11 | ## About 12 | 13 | This is the meta-gem for installing all necessary dependencies and having a convenient way to switch between different Watir drivers. 14 | 15 | Currently supported drivers are: 16 | - [watir-classic](https://github.com/watir/watir-classic) 17 | - [watir-webdriver](https://github.com/watir/watir-webdriver) 18 | 19 | Visit [Watir website](http://watir.com) or refer to each gem's own README and documentation for better understanding of how to use these libraries. 20 | 21 | ## Watir Related Libraries 22 | 23 | ### Integration 24 | 25 | * [watir-rails](https://github.com/watir/watir-rails) for using Watir with Rails. 26 | * [watir-rspec](https://github.com/watir/watir-rspec) for writing your tests with RSpec. 27 | * [watir-robot](https://github.com/semperos/watir-robot) for using Watir with Robot Framework. 28 | * [watir-timecop](https://github.com/p0deje/watir-timecop) for making Watir compatible with Timecop. 29 | 30 | ### Frameworks 31 | 32 | * [page-object](https://github.com/cheezy/page-object) 33 | * [test-page](https://github.com/jarmo/test-page) 34 | * [test-factory](https://github.com/rSmart/TestFactory) 35 | * [watirmark](https://github.com/convio/watirmark) 36 | * [watirsome](https://github.com/p0deje/watirsome) 37 | 38 | ### Other 39 | 40 | * [watir-webdriver-performance](https://github.com/90kts/watir-webdriver-performance) for monitoring web application performance. 41 | * [watir-scroll](https://github.com/p0deje/watir-scroll) for scrolling emulation 42 | * [watir-dom-wait](https://github.com/p0deje/watir-dom-wait) for element waiting based on DOM change 43 | * [watir-get-image-content](https://github.com/orangeudav/watir-get-image-content) for getting image content 44 | * [watir-extensions-element-screenshot](https://github.com/ansoni/watir-extensions-element-screenshot) for making screenshot of specific element 45 | 46 | ## Usage 47 | 48 | Add it into your Gemfile: 49 | ````ruby 50 | gem "watir", "~>4.0" 51 | ```` 52 | 53 | Or install it manually with the following command: 54 | ```` 55 | gem install watir 56 | ```` 57 | 58 | Then in your test file: 59 | ````ruby 60 | require "watir" 61 | browser = Watir::Browser.new 62 | ```` 63 | 64 | The command above will use watir-classic with Internet Explorer on Windows and 65 | watir-webdriver with Firefox on Linux/OS X by default. 66 | 67 | 68 | ## Switching Between Drivers 69 | 70 | There are multiple ways to specify a different driver. 71 | 72 | By specifying different browser via ````#initialize````: 73 | ````ruby 74 | require "watir" 75 | # will use watir-webdriver with Chrome 76 | browser = Watir::Browser.new :chrome 77 | ```` 78 | 79 | By specifying driver manually via ````Watir.driver#=````: 80 | ````ruby 81 | require "watir" 82 | # will use watir-webdriver with Internet Explorer 83 | Watir.driver = :webdriver 84 | browser = Watir::Browser.new :ie 85 | ```` 86 | 87 | Or by using an environment variable ````WATIR_DRIVER````: 88 | ````ruby 89 | require "watir" 90 | # will use watir-classic 91 | ENV["WATIR_DRIVER"] = "classic" 92 | browser = Watir::Browser.new 93 | ```` 94 | 95 | 96 | ## Limitations 97 | 98 | Currently it is possible to use only one driver per Ruby process. All the 99 | methods to switch between drivers won't have any effect after you've opened 100 | your first browser window. 101 | 102 | 103 | ## License 104 | 105 | See [LICENSE](https://github.com/watir/watir/blob/master/LICENSE) for details. 106 | --------------------------------------------------------------------------------