selenium_interaction_statistics 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ chromedriver.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in selenium_interaction_statistics.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Scott Sims
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # SeleniumInteractionStatistics
2
+
3
+ creates a summary of selenium clicks and send keys when the driver is closed
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'selenium_interaction_statistics'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install selenium_interaction_statistics
18
+
19
+ ## Usage
20
+
21
+ include 'selenium_interaction_statistics'
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+ require 'selenium/rake/server_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
9
+
10
+
@@ -0,0 +1,9 @@
1
+ require "selenium_interaction_statistics/version"
2
+ require "selenium-webdriver"
3
+ require "selenium_interaction_statistics/action_counter"
4
+ require "selenium_interaction_statistics/bridge_helper"
5
+ require "selenium_interaction_statistics/driver"
6
+ require "selenium_interaction_statistics/element"
7
+ require "selenium_interaction_statistics/base_formatter"
8
+ module SeleniumInteractionStatistics
9
+ end
@@ -0,0 +1,25 @@
1
+ class ActionCounter
2
+ def initialize
3
+ @clicks=0
4
+ @sent_keys=0
5
+ @found_elements=0
6
+ end
7
+
8
+ attr_accessor :clicks, :sent_keys, :found_elements
9
+
10
+ def add_click
11
+ @clicks+=1
12
+ end
13
+
14
+ def add_send_keys
15
+ @sent_keys+=1
16
+ end
17
+
18
+ def add_found_element
19
+ @found_elements+=1
20
+ end
21
+
22
+ def results
23
+ "\nperformed actions:\n\tfound_elements\t #{found_elements}\n\tclicks\t #{clicks}\n\tsend_keys #{sent_keys}"
24
+ end
25
+ end
@@ -0,0 +1,14 @@
1
+ module RSpec
2
+ module Core
3
+ module Formatters
4
+
5
+ def dump_summary(duration, example_count, failure_count, pending_count)
6
+ @duration = duration
7
+ @example_count = example_count
8
+ @failure_count = failure_count
9
+ @pending_count = pending_count
10
+ @elements_clicked = 0
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,12 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module BridgeHelper
4
+ def action_counter
5
+ if @action_counter.nil?
6
+ @action_counter = ActionCounter.new
7
+ end
8
+ @action_counter
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ module Selenium
2
+ module WebDriver
3
+ class Driver
4
+ def action_counter
5
+ @bridge.action_counter
6
+ end
7
+
8
+ def quit
9
+ bridge.quit
10
+ return action_counter.results
11
+ end
12
+
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ module Selenium
2
+ module WebDriver
3
+ class Element
4
+ def initialize(bridge, id)
5
+ @bridge, @id = bridge, id
6
+ @bridge.action_counter.add_found_element
7
+ end
8
+
9
+
10
+ def click
11
+ bridge.action_counter.add_click
12
+ bridge.clickElement @id
13
+ end
14
+
15
+ def send_keys(*args)
16
+ bridge.action_counter.add_send_keys
17
+ bridge.sendKeysToElement @id, Keys.encode(args)
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module SeleniumInteractionStatistics
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/selenium_interaction_statistics/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Scott Sims"]
6
+ gem.email = ["ssims@homeaway.com"]
7
+ gem.description = %q{creates a summary of selenium clicks and send keys when the driver is closed}
8
+ gem.summary = %q{creates a summary of selenium clicks and send keys when the driver is closed}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "selenium_interaction_statistics"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = SeleniumInteractionStatistics::VERSION
17
+ gem.add_development_dependency('rspec')
18
+ gem.add_dependency('selenium-webdriver')
19
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ describe ActionCounter do
3
+
4
+ specify "increment the clicks count" do
5
+ action_counter=ActionCounter.new
6
+ action_counter.add_click
7
+ action_counter.clicks.should == 1
8
+ end
9
+ specify "increment the send_keys count" do
10
+ action_counter=ActionCounter.new
11
+ action_counter.add_send_keys
12
+ action_counter.sent_keys.should == 1
13
+ end
14
+ specify "increment the found elements count" do
15
+ action_counter=ActionCounter.new
16
+ action_counter.add_found_element
17
+ action_counter.found_elements.should == 1
18
+ end
19
+ specify "print the formatted results" do
20
+ action_counter=ActionCounter.new
21
+ action_counter.add_found_element
22
+ action_counter.add_click
23
+ action_counter.add_send_keys
24
+ action_counter.results.should == "\nperformed actions:\n\tfound_elements\t 1\n\tclicks\t 1\n\tsend_keys 1"
25
+ end
26
+
27
+
28
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ describe Selenium::WebDriver::Driver do
3
+ after(:each) do
4
+ begin
5
+ @driver.quit
6
+ rescue
7
+ end
8
+ end
9
+
10
+ it "should have an action counter included in the driver" do
11
+ @driver=Selenium::WebDriver.for :chrome
12
+ @driver.action_counter.should be_a(ActionCounter)
13
+ @driver.action_counter.clicks.should == 0
14
+ end
15
+ it "should log the results on driver quit" do
16
+ @driver=Selenium::WebDriver.for :chrome
17
+ @driver.quit.should include("performed actions:")
18
+
19
+ end
20
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+ describe Selenium::WebDriver::Element do
3
+ after(:each) do
4
+ begin
5
+ puts @driver.quit
6
+ rescue
7
+ end
8
+ end
9
+ specify 'increment a counter when when a WebDriver element is found' do
10
+ @driver=Selenium::WebDriver.for :chrome
11
+ @driver.navigate.to TEST_PAGE_URL
12
+ @driver.find_element(:id => 'input_text')
13
+ @driver.find_element(:id => 'input_message')
14
+ @driver.action_counter.found_elements.should == 2
15
+ end
16
+
17
+ specify 'increment a counter when click is called from a WebDriver element' do
18
+ @driver=Selenium::WebDriver.for :chrome
19
+ @driver.navigate.to TEST_PAGE_URL
20
+ button=@driver.find_element(:id => 'input_button')
21
+ button.click
22
+ button.click
23
+ @driver.action_counter.clicks.should == 2
24
+ end
25
+ specify 'increment a counter when send_keys is called from a WebDriver element' do
26
+ @driver=Selenium::WebDriver.for :chrome
27
+ @driver.navigate.to TEST_PAGE_URL
28
+ input_text=@driver.find_element(:id => 'input_text')
29
+ input_message=@driver.find_element(:id => 'input_message')
30
+ input_text.send_keys "a"
31
+ input_message.send_keys "b"
32
+ @driver.action_counter.sent_keys.should == 2
33
+ end
34
+
35
+
36
+ end
@@ -0,0 +1,70 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>SeleniumFury Test Page</title>
6
+ <script type="text/javascript">
7
+ function displayMessage() {
8
+ document.getElementById('message').innerHTML = document.form.msgtext.value
9
+ }
10
+ </script>
11
+ </head>
12
+ <body>
13
+
14
+ <div id="message"></div>
15
+
16
+ <form id="form" name="form">
17
+ <label for="textarea">Textarea</label>
18
+ <textarea id="textarea">This is a textarea field.
19
+ </textarea>
20
+ <br/>
21
+ <label for="select">Select</label>
22
+ <select id="select">
23
+ <option value="volvo">Volvo</option>
24
+ <option value="saab">Saab</option>
25
+ <option value="mercedes">Mercedes</option>
26
+ <option value="audi">Audi</option>
27
+ </select>
28
+ <br/>
29
+ <label for="input_button">Button</label>
30
+ <input id="input_button" type="button" value="Click me"/>
31
+ <br/>
32
+ <label for="input_checkbox">Checkbox</label>
33
+ <input id="input_checkbox" type="checkbox"/>
34
+ <br/>
35
+ <label for="input_file">File</label>
36
+ <input id="input_file" type="file"/>
37
+ <br/>
38
+ <input id="input_hidden" type="hidden"/>
39
+ <br/>
40
+ <label for="input_image">Image</label>
41
+ <input id="input_image" type="image" alt="input image"/>
42
+ <br/>
43
+ <label for="input_password">Password</label>
44
+ <input id="input_password" type="password"/>
45
+ <br/>
46
+ <label for="input_radio">Radio</label>
47
+ <input id="input_radio" type="radio"/>
48
+ <br/>
49
+ <label for="input_reset">Reset</label>
50
+ <input id="input_reset" type="reset"/>
51
+ <br/>
52
+ <label for="input_submit">Submit</label>
53
+ <input id="input_submit" type="submit"/>
54
+ <br/>
55
+ <label for="input_text">Text</label>
56
+ <input id="input_text" type="text"/>
57
+ <br/>
58
+ <fieldset>
59
+ <legend>Input test:</legend>
60
+ <label for="input_message">Message Text:</label>
61
+ <input id="input_message" name="msgtext" type="text" />
62
+ <br/>
63
+ <input id="input_msg_button" type="button" value="Click me" onClick="displayMessage()"/>
64
+ </fieldset>
65
+ </form>
66
+ <a id="link111111" href="http://news.ycombinator.com/">Link 1</a>
67
+ <a id="link222222" href="http://yahoo.com">Link 2</a>
68
+ <a id="link333333" href="http://google.com">Link 3</a>
69
+ </body>
70
+ </html>
@@ -0,0 +1,20 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ require 'selenium_interaction_statistics'
8
+ TEST_PAGE_URL="file://"+File.dirname(__FILE__) + "/selenium_interaction_statistics/test_page.html"
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+
20
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: selenium_interaction_statistics
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Scott Sims
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: selenium-webdriver
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: creates a summary of selenium clicks and send keys when the driver is
47
+ closed
48
+ email:
49
+ - ssims@homeaway.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - .rspec
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - lib/selenium_interaction_statistics.rb
61
+ - lib/selenium_interaction_statistics/action_counter.rb
62
+ - lib/selenium_interaction_statistics/base_formatter.rb
63
+ - lib/selenium_interaction_statistics/bridge_helper.rb
64
+ - lib/selenium_interaction_statistics/driver.rb
65
+ - lib/selenium_interaction_statistics/element.rb
66
+ - lib/selenium_interaction_statistics/version.rb
67
+ - selenium_interaction_statistics.gemspec
68
+ - spec/selenium_interaction_statistics/action_counter_spec.rb
69
+ - spec/selenium_interaction_statistics/driver_spec.rb
70
+ - spec/selenium_interaction_statistics/element_spec.rb
71
+ - spec/selenium_interaction_statistics/test_page.html
72
+ - spec/spec_helper.rb
73
+ homepage: ''
74
+ licenses: []
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 1.8.24
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: creates a summary of selenium clicks and send keys when the driver is closed
97
+ test_files:
98
+ - spec/selenium_interaction_statistics/action_counter_spec.rb
99
+ - spec/selenium_interaction_statistics/driver_spec.rb
100
+ - spec/selenium_interaction_statistics/element_spec.rb
101
+ - spec/selenium_interaction_statistics/test_page.html
102
+ - spec/spec_helper.rb
103
+ has_rdoc: