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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe636cb3b0cae995c534f29c111f641c893c231b
4
- data.tar.gz: 7de7589b70e4a487f50fed9e1a6928c308faa896
3
+ metadata.gz: c6f0438dee5cca61ecdc5c88626d2ba92acb1588
4
+ data.tar.gz: 544532f54c7f84faaac5368bd317fbda8fac45bf
5
5
  SHA512:
6
- metadata.gz: 6dc9bab5a99c4db9460d4c3e34fa084adf1f4c3db3b56776be0d0e5c5b5492430f7df0a2c754cafbb63443fe15698647dc15764f8612b052154c627f8284293e
7
- data.tar.gz: 0f853e10baafc6ef04c69c2210a5ccad5d4c4f4bfc225a333134a0ce11dd85be36371b5ab8216228b64c43d362c4681efbf3969b815f4d8bcf23a3fbc5ac341f
6
+ metadata.gz: bcf87becd8a08ccd1fbee22c583d7805ace58eed9fb768498cad864cc12cc1b03ce22817e35fceabd71fc1e415ae8bc67d2ac8b45b2d7bd8fb78bdae316de3ac
7
+ data.tar.gz: 84c964b0e353c55ce4625d1adfe2d3778dd6d4e46db3f40548dd1650e167610531aee93f603646ea34cf27e9e72cbf269feb322244a73406489e8aefefa0db2b
data/.travis.yml CHANGED
@@ -5,3 +5,7 @@ rvm:
5
5
  before_script:
6
6
  - mkdir ~/.yard
7
7
  - bundle exec yard config load_plugins true
8
+ - export DISPLAY=:99
9
+ - sh -e /etc/init.d/xvfb start
10
+ - support/travis.sh
11
+ - export PATH="$(pwd)/bin:$PATH"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### v0.2.0
2
+
3
+ * Update watirsome for Watir 6
4
+
1
5
  ### v0.1.7
2
6
 
3
7
  * Massive refactoring
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## watirsome [![Gem Version](https://badge.fury.io/rb/watirsome.svg)](http://badge.fury.io/rb/watirsome) [![Build Status](https://secure.travis-ci.org/p0deje/watirsome.svg)](http://travis-ci.org/p0deje/watirsome) [![Coverage Status](https://coveralls.io/repos/p0deje/watirsome/badge.svg?branch=master)](https://coveralls.io/r/p0deje/watirsome)
1
+ ## watirsome [![Gem Version](https://badge.fury.io/rb/watirsome.svg)](http://badge.fury.io/rb/watirsome) [![Build Status](https://secure.travis-ci.org/p0deje/watirsome.svg)](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 accessors
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 accessors
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 accessors
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 accessors
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 initializer
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 initializer
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. Currently tested to work only with `watir-webdriver`. Let me know if it works using `watir-classic`.
313
- 2. You cannot use `Watir::Browser#select` method as it's overriden by `Kernel#select`. Use `Watir::Browser#select_list` instead.
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: "Male"
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: "Enter your name"
46
- # select_list :country, name: "Country"
47
- # checkbox :agree, name: "I Agree"
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 = 'My 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-webdriver'
219
+ require 'watir'
208
220
  require 'watirsome/accessors'
209
221
  require 'watirsome/initializers'
210
222
  require 'watirsome/errors'
@@ -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 == 0
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
  #
@@ -1,3 +1,3 @@
1
1
  module Watirsome
2
- VERSION = '0.1.7'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end # Watirsome
data/support/doctest.html CHANGED
@@ -12,5 +12,9 @@
12
12
  <input type="radio" name="sex" value="Male">
13
13
  <input type="radio" name="sex" value="Female">
14
14
  </div>
15
+ <div>
16
+ <div class="visible">Visible</div>
17
+ <div class="visible" style="display: none">Invisible</div>
18
+ </div>
15
19
  </body>
16
20
  </html>
@@ -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-webdriver', '>= 0.6.9'
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.1.7
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-07-04 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: watir-webdriver
14
+ name: watir
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.9
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: 0.6.9
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