watirsome 0.1.7 → 0.2.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 +4 -4
- data/.travis.yml +4 -0
- data/CHANGELOG.md +4 -0
- data/README.md +13 -33
- data/lib/watirsome.rb +25 -13
- data/lib/watirsome/accessors.rb +1 -1
- data/lib/watirsome/initializers.rb +2 -2
- data/lib/watirsome/version.rb +1 -1
- data/support/doctest.html +4 -0
- data/support/doctest_helper.rb +17 -0
- data/support/travis.sh +14 -0
- data/watirsome.gemspec +1 -1
- metadata +7 -6
- data/doctest_helper.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6f0438dee5cca61ecdc5c88626d2ba92acb1588
|
4
|
+
data.tar.gz: 544532f54c7f84faaac5368bd317fbda8fac45bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcf87becd8a08ccd1fbee22c583d7805ace58eed9fb768498cad864cc12cc1b03ce22817e35fceabd71fc1e415ae8bc67d2ac8b45b2d7bd8fb78bdae316de3ac
|
7
|
+
data.tar.gz: 84c964b0e353c55ce4625d1adfe2d3778dd6d4e46db3f40548dd1650e167610531aee93f603646ea34cf27e9e72cbf269feb322244a73406489e8aefefa0db2b
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
## watirsome [](http://badge.fury.io/rb/watirsome) [](http://travis-ci.org/p0deje/watirsome)
|
1
|
+
## watirsome [](http://badge.fury.io/rb/watirsome) [](http://travis-ci.org/p0deje/watirsome)
|
2
2
|
|
3
3
|
Pure dynamic Watir-based page object DSL.
|
4
4
|
|
@@ -126,7 +126,7 @@ page = Page.new(@browser)
|
|
126
126
|
page.link_a('Login') # equals to @browser.div(class: 'layer').a(text: 'Login')
|
127
127
|
```
|
128
128
|
|
129
|
-
#### Element
|
129
|
+
#### Element Accessors
|
130
130
|
|
131
131
|
For each element, accessor method is defined which returns instance of `Watir::Element` (or subtype when applicable).
|
132
132
|
|
@@ -145,13 +145,13 @@ page.section_one_section #=> #<Watir::HTMLElement:0x201b2f994f32c922 selector={
|
|
145
145
|
page.svg_element #=> #<Watir::HTMLElement:0x15288276ab771162 selector={:tag_name=>"svg"}>
|
146
146
|
```
|
147
147
|
|
148
|
-
#### Readable
|
148
|
+
#### Readable Accessors
|
149
149
|
|
150
150
|
For each readable element, accessor method is defined which returns text of that element.
|
151
151
|
|
152
152
|
Read accessor method name is `element_name`.
|
153
153
|
|
154
|
-
Default readable methods are: `[:div, :span, :p, :h1, :h2, :h3, :h4, :h5, :h6, :select_list, :text_field, :textarea]`.
|
154
|
+
Default readable methods are: `[:div, :span, :p, :h1, :h2, :h3, :h4, :h5, :h6, :select_list, :text_field, :textarea, :checkbox, :radio]`.
|
155
155
|
|
156
156
|
You can make other elements readable by adding tag names to `Watirsome.readable`.
|
157
157
|
|
@@ -177,7 +177,7 @@ There is a bit of logic behind text retrieval:
|
|
177
177
|
2. If element is a select list, return text of first selected option
|
178
178
|
3. Otherwise, return text
|
179
179
|
|
180
|
-
#### Clickable
|
180
|
+
#### Clickable Accessors
|
181
181
|
|
182
182
|
For each clickable element, accessor method is defined which performs click on that element.
|
183
183
|
|
@@ -203,13 +203,13 @@ page.login # clicks on link
|
|
203
203
|
page.submit('submit') # clicks on submit input
|
204
204
|
```
|
205
205
|
|
206
|
-
#### Settable
|
206
|
+
#### Settable Accessors
|
207
207
|
|
208
208
|
For each settable element, accessor method is defined which sets value to that element.
|
209
209
|
|
210
210
|
Click accessor method name is `#{element_name}=`.
|
211
211
|
|
212
|
-
Default settable methods are: `[:text_field, :file_field, :textarea, :checkbox]`.
|
212
|
+
Default settable methods are: `[:text_field, :file_field, :textarea, :checkbox, :select_list]`.
|
213
213
|
|
214
214
|
You can make other elements settable by adding tag names to `Watirsome.settable`.
|
215
215
|
|
@@ -222,41 +222,22 @@ class Page
|
|
222
222
|
|
223
223
|
text_field :username, label: 'Username'
|
224
224
|
input :date, type: 'date'
|
225
|
+
select_list :country, label: 'Country'
|
225
226
|
end
|
226
227
|
|
227
228
|
page = Page.new(@browser)
|
228
229
|
page.username = 'Username' # sets value of username text field
|
229
230
|
page.date = '2013-01-01', :return # sends text to element and hits "Enter"
|
231
|
+
page.country = 'Russia' # selects option with "Russia" text
|
230
232
|
```
|
231
233
|
|
232
234
|
If found element responds to `#set`, accessor calls it. Otherwise, `#send_keys` is used.
|
233
235
|
|
234
|
-
#### Selectable accessors
|
235
|
-
|
236
|
-
For each selectable element, accessor method is defined which selects opton of that element.
|
237
|
-
|
238
|
-
Click accessor method name is `#{element_name}=`.
|
239
|
-
|
240
|
-
Default selectable methods are: `[:select_list]`.
|
241
|
-
|
242
|
-
You can make other elements selectable by adding tag names to `Watirsome.selectable`. Though, why would you want?
|
243
|
-
|
244
|
-
```ruby
|
245
|
-
class Page
|
246
|
-
include Watirsome
|
247
|
-
|
248
|
-
select_list :country, label: 'Country'
|
249
|
-
end
|
250
|
-
|
251
|
-
page = Page.new(@browser)
|
252
|
-
page.country = 'Russia' #=> selects option with "Russia" text
|
253
|
-
```
|
254
|
-
|
255
236
|
### Initializers
|
256
237
|
|
257
238
|
Watirsome provides you with initializers DSL to dynamically modify your pages/regions behavior.
|
258
239
|
|
259
|
-
#### Page
|
240
|
+
#### Page Initializer
|
260
241
|
|
261
242
|
Each page may define `#initialize_page` method which will be used as page constructor.
|
262
243
|
|
@@ -273,7 +254,7 @@ Page.new(@browser)
|
|
273
254
|
#=> 'Initialized!'
|
274
255
|
```
|
275
256
|
|
276
|
-
#### Region
|
257
|
+
#### Region Initializer
|
277
258
|
|
278
259
|
Each region you include/extend may define `#initialize_region` method which will be called after page constructor.
|
279
260
|
|
@@ -309,9 +290,8 @@ Regions are being cached, so, once initialized, they won't be executed if you ca
|
|
309
290
|
|
310
291
|
### Limitations
|
311
292
|
|
312
|
-
1.
|
313
|
-
2. You cannot use
|
314
|
-
3. You cannot use block arguments to locate elements for settable/selectable accessors (it makes no sense). However, you can use block arguments for all other accessors.
|
293
|
+
1. You cannot use `Watir::Browser#select` method as it's overriden by `Kernel#select`. Use `Watir::Browser#select_list` instead.
|
294
|
+
2. You cannot use block arguments to locate elements for settable/selectable accessors (it makes no sense). However, you can use block arguments for all other accessors.
|
315
295
|
|
316
296
|
### Contribute
|
317
297
|
|
data/lib/watirsome.rb
CHANGED
@@ -10,19 +10,19 @@
|
|
10
10
|
# div :container, class: 'container'
|
11
11
|
# end
|
12
12
|
#
|
13
|
-
# page = Page.new(browser)
|
14
|
-
# page.body_element #=> browser.element(tag_name: 'body')
|
15
|
-
# page.container_div #=> browser.div(class: 'container')
|
13
|
+
# page = Page.new(@browser)
|
14
|
+
# page.body_element #=> @browser.element(tag_name: 'body')
|
15
|
+
# page.container_div #=> @browser.div(class: 'container')
|
16
16
|
#
|
17
17
|
# @example Read Accessors
|
18
18
|
# class Page
|
19
19
|
# include Watirsome
|
20
20
|
#
|
21
21
|
# div :container, class: 'container'
|
22
|
-
# radio :sex_male, value:
|
22
|
+
# radio :sex_male, value: 'Male'
|
23
23
|
# end
|
24
24
|
#
|
25
|
-
# page = Page.new(browser)
|
25
|
+
# page = Page.new(@browser)
|
26
26
|
# page.container #=> "Container"
|
27
27
|
# page.sex_male_radio.set
|
28
28
|
# page.sex_male #=> true
|
@@ -34,27 +34,39 @@
|
|
34
34
|
# a :open_google, text: 'Open Google'
|
35
35
|
# end
|
36
36
|
#
|
37
|
-
# page = Page.new(browser)
|
37
|
+
# page = Page.new(@browser)
|
38
38
|
# page.open_google
|
39
|
-
# browser.title #=> "Google"
|
39
|
+
# @browser.title #=> "Google"
|
40
40
|
#
|
41
41
|
# @example Set Accessors
|
42
42
|
# class Page
|
43
43
|
# include Watirsome
|
44
44
|
#
|
45
|
-
# text_field :name, placeholder:
|
46
|
-
# select_list :country, name:
|
47
|
-
# checkbox :agree, name:
|
45
|
+
# text_field :name, placeholder: 'Enter your name'
|
46
|
+
# select_list :country, name: 'Country'
|
47
|
+
# checkbox :agree, name: 'I Agree'
|
48
48
|
# end
|
49
49
|
#
|
50
|
-
# page = Page.new(browser)
|
51
|
-
# page.name =
|
50
|
+
# page = Page.new(@browser)
|
51
|
+
# page.name = "My name"
|
52
52
|
# page.name #=> "My name"
|
53
53
|
# page.country = "Russia"
|
54
54
|
# page.country #=> "Russia"
|
55
55
|
# page.agree = true
|
56
56
|
# page.agree #=> true
|
57
57
|
#
|
58
|
+
# @example Locators
|
59
|
+
# class Page
|
60
|
+
# include Watirsome
|
61
|
+
#
|
62
|
+
# div :visible, class: 'visible', visible: true
|
63
|
+
# div :invisible, class: 'visible', visible: false
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# page = Page.new(@browser)
|
67
|
+
# page.visible_div.visible? #=> true
|
68
|
+
# page.invisible_div.visible? #=> false
|
69
|
+
#
|
58
70
|
module Watirsome
|
59
71
|
class << self
|
60
72
|
#
|
@@ -204,7 +216,7 @@ module Watirsome
|
|
204
216
|
end
|
205
217
|
end # Watirsome
|
206
218
|
|
207
|
-
require 'watir
|
219
|
+
require 'watir'
|
208
220
|
require 'watirsome/accessors'
|
209
221
|
require 'watirsome/initializers'
|
210
222
|
require 'watirsome/errors'
|
data/lib/watirsome/accessors.rb
CHANGED
@@ -199,7 +199,7 @@ module Watirsome
|
|
199
199
|
elements = @browser.__send__(method, *watir_args)
|
200
200
|
custom_args.first.each do |k, v|
|
201
201
|
elements.to_a.select! do |e|
|
202
|
-
if e.public_method(:"#{k}?").arity
|
202
|
+
if e.public_method(:"#{k}?").arity.zero?
|
203
203
|
e.__send__(:"#{k}?") == v
|
204
204
|
else
|
205
205
|
e.__send__(:"#{k}?", v)
|
@@ -15,7 +15,7 @@ module Watirsome
|
|
15
15
|
# end
|
16
16
|
# end
|
17
17
|
#
|
18
|
-
# page = Page.new(browser)
|
18
|
+
# page = Page.new(@browser)
|
19
19
|
# page.page_loaded
|
20
20
|
# #=> true
|
21
21
|
#
|
@@ -33,7 +33,7 @@ module Watirsome
|
|
33
33
|
# attr_accessor :page_loaded
|
34
34
|
# end
|
35
35
|
#
|
36
|
-
# page = Page.new(browser)
|
36
|
+
# page = Page.new(@browser)
|
37
37
|
# page.page_loaded
|
38
38
|
# #=> true
|
39
39
|
#
|
data/lib/watirsome/version.rb
CHANGED
data/support/doctest.html
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'watirsome'
|
2
|
+
|
3
|
+
YARD::Doctest.configure do |doctest|
|
4
|
+
doctest.before do
|
5
|
+
opts = {}
|
6
|
+
if ENV['TRAVIS']
|
7
|
+
Selenium::WebDriver::Chrome.path = "#{File.dirname(__FILE__)}/../bin/google-chrome"
|
8
|
+
opts[:args] = ['no-sandbox']
|
9
|
+
end
|
10
|
+
@browser = Watir::Browser.new(:chrome, opts)
|
11
|
+
@browser.goto "data:text/html,#{File.read('support/doctest.html')}"
|
12
|
+
end
|
13
|
+
|
14
|
+
doctest.after do
|
15
|
+
@browser.quit
|
16
|
+
end
|
17
|
+
end
|
data/support/travis.sh
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/bin/bash -ex
|
2
|
+
|
3
|
+
mkdir bin/
|
4
|
+
|
5
|
+
# https://omahaproxy.appspot.com
|
6
|
+
# https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/
|
7
|
+
CHROME_REVISION=386257
|
8
|
+
curl -L -O "http://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64/${CHROME_REVISION}/chrome-linux.zip"
|
9
|
+
unzip chrome-linux.zip
|
10
|
+
ln -s "$(pwd)/chrome-linux/chrome" "$(pwd)/bin/google-chrome"
|
11
|
+
|
12
|
+
curl -L -O "http://chromedriver.storage.googleapis.com/2.21/chromedriver_linux64.zip"
|
13
|
+
unzip chromedriver_linux64.zip
|
14
|
+
ln -s "$(pwd)/chromedriver" "$(pwd)/bin/chromedriver"
|
data/watirsome.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
16
|
s.require_paths = %w[lib]
|
17
17
|
|
18
|
-
s.add_dependency 'watir
|
18
|
+
s.add_dependency 'watir', '>= 6.0'
|
19
19
|
|
20
20
|
s.add_development_dependency 'yard-doctest', '>= 0.1.5'
|
21
21
|
s.add_development_dependency 'rake'
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watirsome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-21 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:
|
19
|
+
version: '6.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:
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: yard-doctest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,13 +79,14 @@ files:
|
|
79
79
|
- LICENSE.md
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
82
|
-
- doctest_helper.rb
|
83
82
|
- lib/watirsome.rb
|
84
83
|
- lib/watirsome/accessors.rb
|
85
84
|
- lib/watirsome/errors.rb
|
86
85
|
- lib/watirsome/initializers.rb
|
87
86
|
- lib/watirsome/version.rb
|
88
87
|
- support/doctest.html
|
88
|
+
- support/doctest_helper.rb
|
89
|
+
- support/travis.sh
|
89
90
|
- watirsome.gemspec
|
90
91
|
homepage: http://github.com/p0deje/watirsome
|
91
92
|
licenses: []
|
data/doctest_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'watirsome'
|
2
|
-
|
3
|
-
def browser
|
4
|
-
@browser ||= begin
|
5
|
-
browser = Watir::Browser.new(:phantomjs)
|
6
|
-
browser.goto "data:text/html,#{File.read('support/doctest.html')}"
|
7
|
-
|
8
|
-
browser
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
YARD::Doctest.configure do |doctest|
|
13
|
-
doctest.after do
|
14
|
-
@browser.quit if @browser
|
15
|
-
end
|
16
|
-
end
|