selenium-more 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 63ae75641b9efc300ba56fb3d72cecd2068d0ec6
4
+ data.tar.gz: 2eaeed4faf822998b045979f90b6b59d2faebffa
5
+ SHA512:
6
+ metadata.gz: 966d307b497a283fa7f241b7ae90d196f8548c4fe6f2ff50e938c4e723739fefec4faa164589609b21f01f0bca559926f517b91027acab1535b95cbe75d71cb3
7
+ data.tar.gz: fc643f7b390e63f4715ec0cfe14ce68cc5a269c67b688b6db0a7fa97f34d0894074d9a398d0a20343be5f94717fdcb679a3d3bcd6cf272400a3841fbf8fd20c4
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ .ruby-version
20
+ .ruby-gemset
21
+ .rspec
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in selenium-more.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 okitan
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,75 @@
1
+ # Selenium::More [![Build Status](https://travis-ci.org/okitan/selenium-more.png?branch=master)](https://travis-ci.org/okitan/selenium-more)
2
+
3
+ Selenium WebDriver utilities.
4
+
5
+ ## Features
6
+
7
+ * hook interface to selenium-webdriver
8
+ * utilities for test
9
+ * session management
10
+ * implicit and explicit wait
11
+ * retry
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ gem 'selenium-more'
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install selenium-more
26
+
27
+ ## Usage
28
+
29
+ ### Hooks
30
+
31
+ When you include ::Selenium::More::Hooks to ::Selenium::WebDriver::Driver, you can add before/after hook to any existing driver function.
32
+
33
+ Sample Code:
34
+ ```ruby
35
+ class Selenium::WebDriver::Driver
36
+ include Selenium::More::Hooks
37
+
38
+ hook :get, before: ->(driver) { puts driver.current_url }
39
+ after: ->(driver, ret) { puts driver.currnent_url }
40
+ end
41
+
42
+ driver = Selenium::WebDriver.for :phantomjs
43
+
44
+ drvier.get "http://example.com/"
45
+ ```
46
+
47
+ It prints.
48
+ ```
49
+ about:blank
50
+ http://example.com/
51
+ ```
52
+
53
+ ### session management
54
+
55
+ T.B.D.
56
+
57
+ ### Implicit and Explicit wait
58
+
59
+ T.B.D.
60
+
61
+ ### retry
62
+
63
+ T.B.D.
64
+
65
+ ## Development
66
+
67
+ java is needed to run selenium-server-standalone
68
+
69
+ ## Contributing
70
+
71
+ 1. Fork it ( http://github.com/<my-github-username>/selenium-more/fork )
72
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
73
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
74
+ 4. Push to the branch (`git push origin my-new-feature`)
75
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = FileList['spec/**/*_spec.rb']
7
+ end
8
+
9
+ task default: :spec
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,29 @@
1
+ require "selenium/webdriver"
2
+
3
+ module Selenium::More
4
+ module Hooks
5
+ def self.included(base)
6
+ base.extend(ClassMethods)
7
+ end
8
+
9
+ module ClassMethods
10
+ def hook(method, opts)
11
+ if instance_methods.include?(method.to_sym)
12
+ mod = Module.new do
13
+ define_method method do |*args|
14
+ opts[:before].call(self) if opts[:before]
15
+ ret = super(*args)
16
+ opts[:after].call(self, ret) if opts[:after]
17
+
18
+ ret
19
+ end
20
+ end
21
+
22
+ prepend(mod)
23
+ else
24
+ raise NoMethodError, "no #{method} to hook"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ require "selenium/webdriver"
2
+
3
+ module Selenium
4
+ module More
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ require "selenium/more"
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "selenium-more"
4
+ spec.version = File.read(File.expand_path("VERSION", File.dirname(__FILE__))).chomp
5
+ spec.authors = ["okitan"]
6
+ spec.email = ["okitakunio@gmail.com"]
7
+ spec.summary = "Selenium WebDriver Utilities."
8
+ spec.description = <<_DESCRIPTION_
9
+ Selenium WebDriver Utilities.
10
+ - Many hook points for selenium-webdirver.
11
+ - Manage multiple sessions
12
+ - Implicit and Explicit wait
13
+ - Retry
14
+ _DESCRIPTION_
15
+ spec.homepage = "https://github.com/okitan/selenium-more"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.required_ruby_version = "~> 2.0"
24
+
25
+ spec.add_runtime_dependency "selenium-webdriver"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.5"
28
+ spec.add_development_dependency "rake"
29
+
30
+ # test
31
+ spec.add_runtime_dependency "rspec", "~> 3.0.0.beta"
32
+
33
+ # to run selenium-standalone-server
34
+ spec.add_runtime_dependency "selenium-connect"
35
+
36
+ # auto test
37
+ spec.add_runtime_dependency "guard-rspec"
38
+ end
@@ -0,0 +1,66 @@
1
+ require "spec_helper"
2
+
3
+ require "selenium/more/hooks"
4
+
5
+ describe Selenium::WebDriver::Driver, "with", Selenium::More::Hooks do
6
+ context ".hook" do
7
+ context "of before and after" do
8
+ let(:klass) do
9
+ Class.new(described_class) do
10
+ include Selenium::More::Hooks
11
+
12
+ def spy
13
+ @spy ||= []
14
+ end
15
+
16
+ hook :current_url, before: ->(driver) { driver.spy << "before_hook1" },
17
+ after: ->(driver, ret) { driver.spy << "after_hook1" }
18
+ hook :current_url, before: ->(driver) { driver.spy << "before_hook2" },
19
+ after: ->(driver, ret) { driver.spy << "after_hook2" }
20
+ end
21
+ end
22
+
23
+ let(:original_driver) { described_class.for :remote, desired_capabilities: :htmlunit }
24
+ let(:driver) { klass.for :remote, desired_capabilities: :htmlunit }
25
+
26
+ it "is called before and after in order" do
27
+ expect { driver.current_url }.to change { driver.spy }.to(%w[ before_hook2 before_hook1 after_hook1 after_hook2 ])
28
+ end
29
+
30
+ it "returns value as is" do
31
+ expect(driver.current_url).to eq(original_driver.current_url)
32
+ end
33
+ end
34
+
35
+ context "of after" do
36
+ let(:klass) do
37
+ Class.new(described_class) do
38
+ include Selenium::More::Hooks
39
+
40
+ attr_accessor :spy
41
+
42
+ hook :current_url, after: ->(driver, ret) { driver.spy = ret }
43
+ end
44
+ end
45
+
46
+ let(:original_driver) { described_class.for :remote, desired_capabilities: :htmlunit }
47
+ let(:driver) { klass.for :remote, desired_capabilities: :htmlunit }
48
+
49
+ it "passes ret value to after block" do
50
+ expect { driver.current_url }.to change { driver.spy }.to(original_driver.current_url)
51
+ end
52
+ end
53
+
54
+ context "when no method is available" do
55
+ it "raise NoMethodError" do
56
+ expect {
57
+ Class.new(described_class) do
58
+ include Selenium::More::Hooks
59
+
60
+ hook :hoge, before: ->(driver) { driver }
61
+ end
62
+ }.to raise_exception(NoMethodError, "no hoge to hook")
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe Selenium::More do
4
+ it "works" do
5
+ expect { described_class }.not_to raise_exception
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ require "selenium/more"
2
+
3
+ require "selenium_connect"
4
+
5
+ RSpec.configure do |config|
6
+ config.filter_run :focus
7
+ config.run_all_when_everything_filtered = true
8
+ config.order = 'random'
9
+
10
+ config.before(:suite) do
11
+ ::SeleniumConnect.start ::SeleniumConnect::Configuration.new browser: "htmlunit"
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: selenium-more
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - okitan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: selenium-webdriver
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0.beta
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0.beta
69
+ - !ruby/object:Gem::Dependency
70
+ name: selenium-connect
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: |
98
+ Selenium WebDriver Utilities.
99
+ - Many hook points for selenium-webdirver.
100
+ - Manage multiple sessions
101
+ - Implicit and Explicit wait
102
+ - Retry
103
+ email:
104
+ - okitakunio@gmail.com
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - ".gitignore"
110
+ - ".travis.yml"
111
+ - Gemfile
112
+ - Guardfile
113
+ - LICENSE.txt
114
+ - README.md
115
+ - Rakefile
116
+ - VERSION
117
+ - lib/selenium-more.rb
118
+ - lib/selenium/more.rb
119
+ - lib/selenium/more/hooks.rb
120
+ - selenium-more.gemspec
121
+ - spec/lib/selenium/more/hooks_spec.rb
122
+ - spec/lib/selnium-more_spec.rb
123
+ - spec/spec_helper.rb
124
+ homepage: https://github.com/okitan/selenium-more
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - "~>"
135
+ - !ruby/object:Gem::Version
136
+ version: '2.0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.2.1
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Selenium WebDriver Utilities.
148
+ test_files:
149
+ - spec/lib/selenium/more/hooks_spec.rb
150
+ - spec/lib/selnium-more_spec.rb
151
+ - spec/spec_helper.rb