watir-customize_elements 0.0.2 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +5 -5
- data/lib/watir-customize_elements.rb +18 -42
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 02d2bf600d8f64b491c3057286b5d5cd698030dc745d5749b26af8e9e25ae4db
|
4
|
+
data.tar.gz: 4db444ec6b665da5361ab83691f50e0752ca94cb8eec5b774ca66e17ce77a9bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bfecf704f0a9908ca65d6442fd19418707c73dd070440c0795b2afba80e9d3a1dc43615a78c96e5bb763b41ba34b95616c8ce99605750fa746ef317303eeb7f
|
7
|
+
data.tar.gz: '08988a136d18ed765dddb48288f94f20d2273f2c1158dc2d354acb658d0f7e269fe0d4981cd9a70c7ef16b570ff70816373d98b4aea9fba102f5f3884ba8bd41'
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# watir-customize_elements
|
2
|
-
The purpose of this gem is to enable Watir
|
2
|
+
The purpose of this gem is to enable Watir and page-object gem to work with custom, non-standard HTML element tag names.
|
3
3
|
|
4
|
-
While Watir
|
4
|
+
While Watir and the page-object gem do not support non-standard HTML tags, we encountered many cases in our testing when we needed to use such elements.
|
5
5
|
Although it's possible to register custom elements with PageObject via [widgets](https://github.com/cheezy/page-object/wiki/Widgets-%28registering-custom-elements-with-PageObject%29), and to add support for it in Watir, the process of doing so for each custom element got tedious.
|
6
|
-
That's why we created this gem. It automatically instantiates custom HTML tag names into watir
|
6
|
+
That's why we created this gem. It automatically instantiates custom HTML tag names into watir and/or page-object gem from a few lines in a simple yml file.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
Add this line to your application's Gemfile:
|
@@ -25,10 +25,10 @@ $ gem install watir-customize_elements
|
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
- Create a yml file (call it whatever you like), and include the name and path as an env argument named `CUSTOM_ELEMENTS_CONFIG_PATH`. See explanation at the end of this section
|
28
|
-
- Require watir-customize_elements **after** requiring watir
|
28
|
+
- Require watir-customize_elements **after** requiring watir and/or page-object.
|
29
29
|
- If you don't want to pass `ENV[CUSTOM_ELEMENTS_CONFIG_PATH]` from the command line, set it **before** requiring watir-customize_elements
|
30
30
|
```ruby
|
31
|
-
require 'watir
|
31
|
+
require 'watir'
|
32
32
|
require 'page-object'
|
33
33
|
ENV['CUSTOM_ELEMENTS_CONFIG_PATH'] = 'path\to\custom_elements_file.yml'
|
34
34
|
require 'watir-customize_elements'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'watir
|
1
|
+
require 'watir'
|
2
2
|
require 'page-object'
|
3
3
|
require 'yaml'
|
4
4
|
|
@@ -39,6 +39,23 @@ unless WatirCustomizeElements.custom_elements.nil?
|
|
39
39
|
module Watir
|
40
40
|
# Extending Container module
|
41
41
|
module Container
|
42
|
+
def extract_selector(selectors)
|
43
|
+
case selectors.size
|
44
|
+
when 2
|
45
|
+
msg = "Using ordered parameters to locate elements (:#{selectors.first}, #{selectors.last.inspect})"
|
46
|
+
Watir.logger.deprecate msg,
|
47
|
+
"{#{selectors.first}: #{selectors.last.inspect}}",
|
48
|
+
id: [:selector_parameters]
|
49
|
+
return {selectors[0] => selectors[1]}
|
50
|
+
when 1
|
51
|
+
obj = selectors.first
|
52
|
+
return obj if obj.is_a? Hash
|
53
|
+
when 0
|
54
|
+
return {}
|
55
|
+
end
|
56
|
+
|
57
|
+
raise ArgumentError, "expected Hash, got #{selectors.inspect}"
|
58
|
+
end
|
42
59
|
# Do the following for each custom element to add
|
43
60
|
WatirCustomizeElements.custom_elements.each do |key, values|
|
44
61
|
# Defines the element in Watir as a method
|
@@ -56,47 +73,6 @@ unless WatirCustomizeElements.custom_elements.nil?
|
|
56
73
|
end
|
57
74
|
end
|
58
75
|
|
59
|
-
module Watir
|
60
|
-
# Expanding the case statement in the normalize_selector method to include custom attributes,
|
61
|
-
# since the custom element does not recognize all attributes by default.
|
62
|
-
if Gem.loaded_specs["watir-webdriver"].version <= Gem::Version.create('0.9.1')
|
63
|
-
class ElementLocator
|
64
|
-
alias :old_normalize_selector :normalize_selector
|
65
|
-
|
66
|
-
def normalize_selector(how, what)
|
67
|
-
case how
|
68
|
-
# supporting "name" attribute
|
69
|
-
when :name
|
70
|
-
[how, what]
|
71
|
-
else
|
72
|
-
old_normalize_selector(how, what)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
else
|
77
|
-
module Locators
|
78
|
-
class Element
|
79
|
-
|
80
|
-
# Expanding the case statement in the normalize_selector method to include custom attributes,
|
81
|
-
# since the custom element does not recognize all attributes by default.
|
82
|
-
class SelectorBuilder
|
83
|
-
alias :old_normalize_selector :normalize_selector
|
84
|
-
|
85
|
-
def normalize_selector(how, what)
|
86
|
-
case how
|
87
|
-
# supporting "name" attribute
|
88
|
-
when :name
|
89
|
-
[how, what]
|
90
|
-
else
|
91
|
-
old_normalize_selector(how, what)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
76
|
end
|
101
77
|
|
102
78
|
if WatirCustomizeElements.modules['page_object']
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir-customize_elements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Miller, Shani Raby, Matan Goren, Ronnie Harpaz
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: watir
|
14
|
+
name: watir
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: page-object
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,7 +55,7 @@ homepage: https://github.com/myheritage/watir-customize_elements
|
|
55
55
|
licenses:
|
56
56
|
- Apache-2.0
|
57
57
|
metadata: {}
|
58
|
-
post_install_message:
|
58
|
+
post_install_message:
|
59
59
|
rdoc_options: []
|
60
60
|
require_paths:
|
61
61
|
- lib
|
@@ -70,9 +70,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '0'
|
72
72
|
requirements: []
|
73
|
-
|
74
|
-
|
75
|
-
signing_key:
|
73
|
+
rubygems_version: 3.3.14
|
74
|
+
signing_key:
|
76
75
|
specification_version: 4
|
77
76
|
summary: Gem for adding custom elements to Watir-webdriver and page-object gem
|
78
77
|
test_files: []
|