watir_drops 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +41 -0
- data/lib/watir_drops/page_object.rb +66 -39
- data/watir_drops.gemspec +3 -2
- metadata +31 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d66c2965a5fd282b640c17434bdbf4b428560a77
|
4
|
+
data.tar.gz: e82eb9a8b5c37bb0508de2c02b0e706e74b66816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a5423e07816e4b930deb21c8cc0a2db17e4bbcdb511efd79c61086ff8f50dc4214053bd2b30e6f0bc717faf341791aca89961d7c378e595829758c6863d0bcf
|
7
|
+
data.tar.gz: fdee13b41ebdd7e1f694f260b706a89a272c6eff74f49cf8a41f61d97b86699efcdf887e310037e7b8a0da28e6828e977d40ad501f5729a033fa7e19f79711d4
|
data/CHANGES.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
### 0.4.0 (2016-02-12)
|
2
|
+
|
3
|
+
* define elements & collections with locator hashes as well as blocks
|
4
|
+
* supports auto-form filling data from any object that converts to a hash
|
5
|
+
* allow setting browser with class method
|
6
|
+
* runtime dependency removed for watir_model and watir_session
|
7
|
+
|
8
|
+
### 0.3.4 (2016-01-25)
|
9
|
+
|
10
|
+
* elements inherited in subclasses
|
11
|
+
|
12
|
+
### 0.3.3 (2016-01-30)
|
13
|
+
|
14
|
+
* switch from test-model to watir_model
|
15
|
+
* update to latest watir_session implementation
|
16
|
+
|
17
|
+
### 0.3.2 (2016-01-25)
|
18
|
+
|
19
|
+
* clear field before typing into it
|
20
|
+
|
21
|
+
### 0.3.1 (2016-01-25)
|
22
|
+
|
23
|
+
* wait for element before interacting with it
|
24
|
+
|
25
|
+
### 0.3.0 (2016-01-24)
|
26
|
+
|
27
|
+
* Singleton replaced with usage of watir_session gem
|
28
|
+
* page_url methods can take parameters
|
29
|
+
* Default form filling method with usage of test-model gem
|
30
|
+
* Pluralizing element names obtains collections of those elements
|
31
|
+
* `#visit` and `#use` methods provided for passing blocks to the Page Object
|
32
|
+
|
33
|
+
### 0.1.1 (2015-07-30)
|
34
|
+
|
35
|
+
* Browser session stored in singleton
|
36
|
+
* Page Objects initialize without parameters
|
37
|
+
* Default actions for setters on elements
|
38
|
+
|
39
|
+
### 0.1.0 (2015-07-15)
|
40
|
+
|
41
|
+
* initial commit
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'watir-webdriver'
|
2
2
|
require 'active_support/inflector'
|
3
3
|
|
4
4
|
module WatirDrops
|
@@ -6,7 +6,7 @@ module WatirDrops
|
|
6
6
|
|
7
7
|
class << self
|
8
8
|
|
9
|
-
attr_writer :
|
9
|
+
attr_writer :element_list
|
10
10
|
|
11
11
|
def page_url
|
12
12
|
define_method("goto") do |*args|
|
@@ -14,48 +14,68 @@ module WatirDrops
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
@
|
17
|
+
def element_list
|
18
|
+
@element_list ||= []
|
19
19
|
end
|
20
20
|
|
21
21
|
def inherited(subclass)
|
22
|
-
subclass.
|
22
|
+
subclass.element_list = element_list.dup
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
define_method(
|
27
|
-
|
28
|
-
|
25
|
+
Watir::Container.instance_methods(false).each do |class_method_name|
|
26
|
+
define_method(class_method_name) do |instance_method_name, locator = {}, &block|
|
27
|
+
define_method(instance_method_name) do |*args|
|
28
|
+
if block.is_a? Proc
|
29
|
+
raise StandardError, 'Can not define element with both locator and block' unless locator.empty?
|
30
|
+
expected_class = browser.send(class_method_name).class
|
31
|
+
element = self.instance_exec(*args, &block)
|
32
|
+
return element if element.is_a? expected_class
|
33
|
+
raise StandardError, "#{instance_method_name} method was defined as a #{expected_class}, but is a #{element.class}"
|
34
|
+
else
|
35
|
+
browser.send(class_method_name, locator)
|
36
|
+
end
|
37
|
+
end
|
29
38
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
39
|
+
define_method("#{instance_method_name}=") do |val|
|
40
|
+
watir_element = self.send(instance_method_name)
|
41
|
+
watir_element.wait_until_present
|
42
|
+
case watir_element
|
43
|
+
when Watir::Radio
|
44
|
+
watir_element.set if val
|
45
|
+
when Watir::CheckBox
|
46
|
+
val ? watir_element.set : watir_element.clear
|
47
|
+
when Watir::Select
|
48
|
+
watir_element.select val
|
49
|
+
when Watir::Button
|
50
|
+
watir_element.click
|
51
|
+
# TODO - Email & Password types are not set to UserEditable in Watir
|
52
|
+
when Watir::Input
|
53
|
+
watir_element.wd.clear
|
54
|
+
watir_element.send_keys val
|
55
|
+
else
|
56
|
+
watir_element.click if val
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
define_method(instance_method_name.to_s.pluralize) do |*args|
|
61
|
+
if block.is_a? Proc
|
62
|
+
expected_class = browser.send(class_method_name.to_s.pluralize).class
|
35
63
|
|
64
|
+
single_element = self.instance_exec(*args, &block)
|
65
|
+
parent = single_element.instance_variable_get('@parent')
|
66
|
+
selector = single_element.instance_variable_get('@selector')
|
67
|
+
element_type = selector.delete(:tag_name) || 'element'
|
68
|
+
element = parent.send(element_type.pluralize, selector)
|
36
69
|
|
37
|
-
|
38
|
-
|
39
|
-
watir_element.wait_until_present
|
40
|
-
case watir_element
|
41
|
-
when Watir::Radio
|
42
|
-
watir_element.set if val
|
43
|
-
when Watir::CheckBox
|
44
|
-
val ? watir_element.set : watir_element.clear
|
45
|
-
when Watir::Select
|
46
|
-
watir_element.select val
|
47
|
-
when Watir::Button
|
48
|
-
watir_element.click
|
49
|
-
# TODO - Email & Password types are not set to UserEditable in Watir
|
50
|
-
when Watir::Input
|
51
|
-
watir_element.wd.clear
|
52
|
-
watir_element.send_keys val
|
70
|
+
return element if element.is_a?(expected_class) || class_method_name == :element
|
71
|
+
raise StandardError, "#{instance_method_name} method was defined as a #{expected_class}, but is a #{element.class}"
|
53
72
|
else
|
54
|
-
|
73
|
+
browser.send(class_method_name.to_s.pluralize, locator)
|
74
|
+
end
|
55
75
|
end
|
56
|
-
end
|
57
76
|
|
58
|
-
|
77
|
+
element_list << instance_method_name.to_sym
|
78
|
+
end
|
59
79
|
end
|
60
80
|
|
61
81
|
def visit(*args)
|
@@ -69,18 +89,25 @@ module WatirDrops
|
|
69
89
|
new.tap { yield if block_given? }
|
70
90
|
end
|
71
91
|
|
72
|
-
|
92
|
+
def browser=(*args)
|
93
|
+
@@browser = block_given? ? yield(args) : args.first
|
94
|
+
end
|
73
95
|
|
74
|
-
|
96
|
+
def browser
|
97
|
+
@@browser || (WatirSession.browser if defined? WatirSession)
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
75
101
|
|
76
|
-
def
|
77
|
-
|
102
|
+
def browser
|
103
|
+
self.class.browser
|
78
104
|
end
|
79
105
|
|
80
106
|
def fill_form(model)
|
81
|
-
|
107
|
+
model = model.to_h unless model.is_a? Hash
|
108
|
+
intersect = self.class.element_list & model.keys
|
82
109
|
intersect.each do |val|
|
83
|
-
self.send("#{val}=", model
|
110
|
+
self.send("#{val}=", model[val])
|
84
111
|
end
|
85
112
|
end
|
86
113
|
|
data/watir_drops.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'watir_drops'
|
5
|
-
spec.version = '0.
|
5
|
+
spec.version = '0.4.0'
|
6
6
|
spec.authors = ['Titus Fortner']
|
7
7
|
spec.email = ['titusfortner@gmail.com']
|
8
8
|
|
@@ -15,10 +15,11 @@ application information, allowing it to be decoupled from the tests}
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
|
18
|
-
spec.add_runtime_dependency 'watir_session', '~> 0.2'
|
19
18
|
spec.add_runtime_dependency 'activesupport', '~> 3.0'
|
20
19
|
|
21
20
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
22
21
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
22
|
spec.add_development_dependency 'rspec'
|
23
|
+
spec.add_development_dependency 'factory_girl'
|
24
|
+
spec.add_development_dependency 'watir_session', '~> 0.2'
|
24
25
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir_drops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: watir_session
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.2'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.2'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: activesupport
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +66,34 @@ dependencies:
|
|
80
66
|
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: factory_girl
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
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: watir_session
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.2'
|
83
97
|
description: |-
|
84
98
|
This gem leverages the Watir test framework to allow for easy modeling of specific web
|
85
99
|
application information, allowing it to be decoupled from the tests
|
@@ -90,6 +104,7 @@ extensions: []
|
|
90
104
|
extra_rdoc_files: []
|
91
105
|
files:
|
92
106
|
- ".gitignore"
|
107
|
+
- CHANGES.md
|
93
108
|
- Gemfile
|
94
109
|
- LICENSE.txt
|
95
110
|
- README.md
|