webdriver-highlighter 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +58 -0
- data/Rakefile +1 -0
- data/lib/webdriver-highlighter.rb +38 -0
- data/webdriver-highlighter.gemspec +23 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6bdfdd7f6402e6c8b44c28d1ea729a0c7502530e
|
4
|
+
data.tar.gz: e1f8d6749f766bbf16ca560e777fc32b4fcb4719
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e1dcf59ae4a127c2ba366777fd8b183c665f5c7d70e11234dc7e5b3615eab82efc03ddd5ae9a0f54d74191c4331e6a8e43f3cb2a9bdb59a8a06b9826fc667e21
|
7
|
+
data.tar.gz: da6385635ed137c76addc7174ac0364529a8bc2dc6e381de6ddb98b639992da563d77a21dcd2ba235a6aae7e770703ff27bacccf0ecd4c92a12ba6e6dba067d9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alex Rodionov
|
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,58 @@
|
|
1
|
+
# webdriver-highlighter [](http://badge.fury.io/rb/webdriver-highlighter)
|
2
|
+
|
3
|
+
Automatically highlights element (changes it background color for a moment) before you click it or change its value.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
gem 'webdriver-highlighter'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
$ gem install webdriver-highlighter
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Just pass instance of `WebDriverHighlighter` as `:listener` option for WebDriver instantiation.
|
28
|
+
|
29
|
+
With Selenium-WebDriver:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'webdriver-highlighter'
|
33
|
+
Selenium::WebDriver.for(:firefox, listener: WebDriverHighlighter.new)
|
34
|
+
```
|
35
|
+
|
36
|
+
With Watir-WebDriver:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
require 'webdriver-highlighter'
|
40
|
+
Watir::Browser.new(:firefox, listener: WebDriverHighlighter.new)
|
41
|
+
```
|
42
|
+
|
43
|
+
With Capybara (not tested actually):
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
require 'webdriver-highlighter'
|
47
|
+
Capybara.register_driver :selenium do |app|
|
48
|
+
Capybara::Selenium::Driver.new(app, browser: :firefox, listener: WebDriverHighlighter.new)
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
1. Fork it ( http://github.com/p0deje/webdriver-highlighter/fork )
|
55
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
56
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
57
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
58
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'selenium-webdriver'
|
2
|
+
|
3
|
+
|
4
|
+
class WebDriverHighlighter < Selenium::WebDriver::Support::AbstractEventListener
|
5
|
+
|
6
|
+
def before_click(element, driver)
|
7
|
+
flash(element, driver)
|
8
|
+
end
|
9
|
+
|
10
|
+
def before_change_value_of(element, driver)
|
11
|
+
flash(element, driver)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
#
|
17
|
+
# Changes background color of element for a moment.
|
18
|
+
#
|
19
|
+
# @api private
|
20
|
+
#
|
21
|
+
|
22
|
+
def flash(element, driver)
|
23
|
+
css_text = element.style('cssText')
|
24
|
+
driver.execute_script('arguments[0].style.cssText += "; background: magenta; outline: 1px solid magenta"', element)
|
25
|
+
snippet = <<-JS
|
26
|
+
var element = arguments[0], cssText = arguments[1], done = arguments[2];
|
27
|
+
setTimeout(function() {
|
28
|
+
element.style.cssText = cssText;
|
29
|
+
done();
|
30
|
+
}, 100)
|
31
|
+
JS
|
32
|
+
# TODO make sure we rollback to user-defined timeout
|
33
|
+
# blocked by https://code.google.com/p/selenium/issues/detail?id=6608
|
34
|
+
driver.manage.timeouts.script_timeout = 1
|
35
|
+
driver.execute_async_script(snippet, element, css_text)
|
36
|
+
end
|
37
|
+
|
38
|
+
end # WebDriverHighlighter
|
@@ -0,0 +1,23 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'webdriver-highlighter'
|
6
|
+
spec.version = '0.1.0'
|
7
|
+
spec.author = 'Alex Rodionov'
|
8
|
+
spec.email = 'p0deje@gmail.com'
|
9
|
+
spec.summary = 'Automatically highlight used elements in Selenium-WebDriver'
|
10
|
+
spec.description = 'Automatically highlight used elements in Selenium-WebDriver'
|
11
|
+
spec.homepage = 'https://github.com/p0deje/webdriver-highlighter'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_dependency 'selenium-webdriver'
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: webdriver-highlighter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Rodionov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-16 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: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
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
|
+
description: Automatically highlight used elements in Selenium-WebDriver
|
56
|
+
email: p0deje@gmail.com
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- ".gitignore"
|
62
|
+
- Gemfile
|
63
|
+
- LICENSE.txt
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- lib/webdriver-highlighter.rb
|
67
|
+
- webdriver-highlighter.gemspec
|
68
|
+
homepage: https://github.com/p0deje/webdriver-highlighter
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.2.0
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Automatically highlight used elements in Selenium-WebDriver
|
92
|
+
test_files: []
|