Giter VIP home page Giter VIP logo

watirspec's Introduction

watir

Watir Powered By Selenium!

Gem Version Chrome Tests Edge Tests Firefox Tests IE Tests Safari Tests Unit Tests

Using Watir

This README is for people interested in writing code for Watir or gems in the Watir ecosystem that leverage private-api Watir code.

For our users, everything you'll need is on the Watir website: examples, news, guides, additional resources, support information and more.

Procedure for Patches/Pull Requests

  • Fork the project.
  • Clone onto your local machine.
  • Create a new feature branch (bonus points for good names).
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so we don't unintentionally break it in a future version.
  • Commit, do not change Rakefile, gemspec, or CHANGES files, we'll take care of that on release.
  • Make sure it is passing doctests.
  • Make sure it is passing rubocop.
  • Push to your forked repository.
  • Send a pull request.

Developing Extensions

When developing a gem intended to be used with Watir, you can run your code with WatirSpec to make sure that requiring your code does not break something else in Watir.

First, add WatirSpec Rake tasks to your gem:

# Rakefile
require 'watirspec/rake_tasks'
WatirSpec::RakeTasks.new

Second, initialize WatirSpec for your gem:

$ bundle exec rake watirspec:init

This command will walk you through how to customize your code.

Automatic Element Generation

The majority of element methods Watir provides is autogenerated from specifications. This is done by extracting the IDL parts from the spec and processing them with the WebIDL gem.

Generated elements are currently based on the following specifications:

  • HTML (lib/watir/elements/html_elements.rb)
  • SVG (lib/watir/elements/svg_elements.rb)

To run:

$ bundle exec rake html:update
$ bundle exec rake svg:update

Specs

Github Actions

Watir specs are run with Github Actions.

Watir code is tested on Linux with latest versions of supported browsers and all active Ruby versions.

Doctests

Watir uses yard-doctest to directly test our documentation examples.

mkdir ~/.yard
bundle exec yard config -a autoload_plugins yard-doctest
rake yard:doctest

Coveralls

Watir code is run through Coveralls to encourage PRs to ensure all paths in their code have tests associated with them.

Rubocop

Watir is using Rubocop to ensure a consistent style across the code base. It is run with our minimum supported Ruby version (2.3) We have some established exceptions at .rubocop.yml that might need to be tweaked for new code submissions. This can be addressed in the PR as necessary.

Statistics

Element specs are run with Selenium Statistics gem to verify that changes to the code do not dramatically decrease the performance based on wire calls.

Copyright

See LICENSE for details

watirspec's People

Contributors

aderyabin avatar bret avatar durrantm avatar jarib avatar jarmo avatar jkotests avatar jondruse avatar l2g avatar mattparlane avatar p0deje avatar proppy avatar rodneyu215 avatar titusfortner avatar vladimirtcats avatar wincent avatar zeljkofilipin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

watirspec's Issues

Chrome & Multiple Selections

I ran just the specs with chrome 38 and I noticed that there are failing specs for #select and #select_value where multiple selections are expected. These tests weren't failing for me last week, I'm not sure what might have changed other than browser version.

Add window maximize spec

WebDriver exposes #maximize method for window but it's not used anywhere in Watir.

Something like this:

browser.window.maximize

Update specs for nested elements

I'm closing #63, and adding this issue as a placeholder to properly update the watirspecs to ensure the proper functioning of all permutations of nested elements, frames, and their collections.

Add option to always use server

Currently, we serve HTML from the local file system (using file:// URLs) wherever we can to reduce the overhead of going through the server. However, if we want to run watirspec on mobile devices, we'll need to use the server for everything.

This should be an optional flag that can be set in e.g. implementation.rb

Can't find description for what options.to_a is supposed to return

maybe I'm just not looking in the right place, but I can't find anything for what .to_a is supposed to do when used against an OptionCollection object. I see it in the rspec but nothing under the spec for collections or select_list.. is it hiding somewhere else?

is this going to return just the text, or an array of hashes or what?

allow specs to ask for a separate browser

Specs for opening/closing the browser should be able to do this without affecting other specs (i.e. the global browser instance).

With most browsers, those specs can just open and close a separate instance, but this isn't possible with IE where only one browser instance is allowed. So watirspec should provide a way of dealing with this. Perhaps:

in_separate_browser do |b|
  ...
end

The method will then take care of preparing the global browser instance for further use after yielding.

Need option to stop Sinatra logging to stderr

Running the watirspec tests generates a lot of noise:

[2012-02-02 16:12:54] INFO  WEBrick 1.3.1
[2012-02-02 16:12:54] INFO  ruby 1.8.7 (2011-06-30) [i386-mingw32]
[2012-02-02 16:12:54] INFO  WEBrick::HTTPServer#start: pid=3128 port=2001
running watirspec against Watir::IE
.............localhost - - [02/Feb/2012:16:13:02 Pacific Standard Time] "GET /plain_text HTTP/1.1" 200 18
- -> /plain_text
........localhost - - [02/Feb/2012:16:13:05 Pacific Standard Time] "GET /non_control_elements.html HTTP/1.1" 304 0
- -> /non_control_elements.html
localhost - - [02/Feb/2012:16:13:05 Pacific Standard Time] "GET /javascript/helpers.js HTTP/1.1" 304 0
http://localhost:2001/non_control_elements.html -> /javascript/helpers.js

When all I really want to see is this:

running watirspec against Watir::IE
.....................

There is no way, at least no obvious way, to turn off all of the noise from web server logging. I've tried inserting "set :logging, false" alongside the other set commands in lib/server.rb, but that has no effect.

I hope this isn't some dumb thing I'm overlooking. :-)

Future of Watirspec

I stated at the Bazaar that I'd like to see this repo merged in with the existing WebDriver code, since that is the only code base that is currently testable by this repo. The point was made that we'd like Watir to have options to be extensible by code in other repos, which could only be tested if Watirspec remained separate.

I propose:

  1. Remove guards for :watir_classic
  2. Remove need to specify :webdriver in guards
  3. Move current watir-webdriver repo specs into watirspec so that all tests currently applicable to watir are in one place.

I'd also love to see Watir & Ruby Selenium specs run with the same test implementations (same setup, same server implementation and guard structures, etc), but we can talk about that possibility later.

use win32-process for server thread on windows

Since we can't fork() on windows, the server is now running in a Ruby thread, which works fine on JRuby but might cause problems on MRI (at least < 1.9). Probably better to start a new ruby process using Process.create from win32-process.

Add dl.to_hash

Having a #to_hash method on definition lists seems like a useful addition - e.g.

<dl>
      <dt>Address</dt>
      <dd>Foo Bar</dd>

      <dt>City</dt>
      <dd>New York</dd>
</dl>
browser.dl.to_hash 
=> {"Address" => "Foo Bar", "City" => "New York"}

Are there other elements that people commonly turn into a Ruby data structure? We already have Table#hashes.

EADDRNOTAVAIL exceptions

While running watirspec with Chrome, toward the end of the run, everything starts giving this error.

It isn't always starting on the same test, and it isn't always the same wire call. I haven't had any issues with Firefox. Is this a Chrome bug? (I think my system just updated Chrome today). Any ideas what I can do to fix this, regardless?

Errno::EADDRNOTAVAIL: Cannot assign requested address - connect(2) for "127.0.0.1" port 9516
/home/titus/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:879:in initialize' /home/titus/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:879:inopen'
/home/titus/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:879:in block in connect' /home/titus/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/timeout.rb:74:intimeout'
/home/titus/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:878:in connect' /home/titus/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:863:indo_start'
/home/titus/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:852:in `start'

plural selectors

The watir2 branch should have specs for using selectors with the plural methods, which is already implemented in watir-webdriver:


browser.divs(:class => "foo") #=> Watir::DivCollection

avoid alert() in specs

Celerity could easily use JS alert() calls to verify event handling, but this usually blocks on other implementations.

Don't expect exception classes to be available on the top-level object

The specs expect to be able to reference e.g. Watir::Exception::UnknownObjectException as just UnknownObjectException. This is done by including Watir::Exception in the top level object, and frequently leads to NameErrors that pop up in the real world but not in the specs.

We should either (a) fix the specs to reference the full exception name, or (b) only include the Exception module in the specs, not the top level object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.