page-object 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +22 -12
- data/ChangeLog +10 -0
- data/Gemfile +4 -2
- data/Guardfile +1 -1
- data/README.md +2 -2
- data/lib/page-object/accessors.rb +57 -35
- data/lib/page-object/elements/element.rb +26 -0
- data/lib/page-object/locator_generator.rb +46 -0
- data/lib/page-object/platforms/selenium_webdriver/element.rb +6 -6
- data/lib/page-object/platforms/selenium_webdriver/page_object.rb +14 -0
- data/lib/page-object/platforms/watir_webdriver/element.rb +0 -7
- data/lib/page-object/platforms/watir_webdriver/page_object.rb +16 -3
- data/lib/page-object/version.rb +1 -1
- data/page-object.gemspec +7 -10
- metadata +34 -375
- data/features/area.feature +0 -35
- data/features/async.feature +0 -21
- data/features/audio.feature +0 -64
- data/features/bold.feature +0 -21
- data/features/button.feature +0 -98
- data/features/canvas.feature +0 -37
- data/features/check_box.feature +0 -55
- data/features/div.feature +0 -45
- data/features/element.feature +0 -343
- data/features/file_field.feature +0 -40
- data/features/form.feature +0 -43
- data/features/frames.feature +0 -75
- data/features/generic_elements.feature +0 -29
- data/features/gxt_table_extension.feature +0 -23
- data/features/headings.feature +0 -97
- data/features/hidden_field.feature +0 -45
- data/features/html/04-Death_Becomes_Fur.mp4 +0 -0
- data/features/html/04-Death_Becomes_Fur.oga +0 -0
- data/features/html/async.html +0 -36
- data/features/html/double_click.html +0 -13
- data/features/html/failure.html +0 -8
- data/features/html/frame_1.html +0 -18
- data/features/html/frame_2.html +0 -16
- data/features/html/frame_3.html +0 -14
- data/features/html/frames.html +0 -12
- data/features/html/hover.html +0 -12
- data/features/html/iframes.html +0 -12
- data/features/html/images/circle.png +0 -0
- data/features/html/images/img_pulpit.jpg +0 -0
- data/features/html/images/submit.gif +0 -0
- data/features/html/indexed_property.html +0 -55
- data/features/html/modal.html +0 -17
- data/features/html/modal_1.html +0 -38
- data/features/html/modal_2.html +0 -27
- data/features/html/movie.mp4 +0 -0
- data/features/html/movie.ogg +0 -0
- data/features/html/multi_elements.html +0 -145
- data/features/html/nested_elements.html +0 -77
- data/features/html/nested_frame_1.html +0 -1
- data/features/html/nested_frame_2.html +0 -11
- data/features/html/nested_frame_3.html +0 -14
- data/features/html/nested_frames.html +0 -10
- data/features/html/planets.gif +0 -0
- data/features/html/static_elements.html +0 -194
- data/features/html/success.html +0 -8
- data/features/html/sun.gif +0 -0
- data/features/html/sun.html +0 -7
- data/features/html/widgets.html +0 -20
- data/features/image.feature +0 -50
- data/features/indexed_property.feature +0 -117
- data/features/italic.feature +0 -21
- data/features/javascript.feature +0 -28
- data/features/label.feature +0 -46
- data/features/link.feature +0 -52
- data/features/list_item.feature +0 -36
- data/features/modal_dialog.feature +0 -15
- data/features/multi_elements.feature +0 -498
- data/features/nested_elements.feature +0 -117
- data/features/ordered_list.feature +0 -56
- data/features/page_level_actions.feature +0 -90
- data/features/paragraph.feature +0 -35
- data/features/radio_button.feature +0 -58
- data/features/radio_button_group.feature +0 -29
- data/features/sample-app/public/audio_video.html +0 -23
- data/features/sample-app/public/jquery-1.3.2.js +0 -4376
- data/features/sample-app/public/jquery.html +0 -30
- data/features/sample-app/public/prototype-1.6.0.3.js +0 -4320
- data/features/sample-app/public/prototype.html +0 -35
- data/features/sample-app/sample_app.rb +0 -35
- data/features/section.feature +0 -136
- data/features/select_list.feature +0 -86
- data/features/span.feature +0 -37
- data/features/step_definitions/accessor_steps.rb +0 -64
- data/features/step_definitions/area_steps.rb +0 -19
- data/features/step_definitions/async_steps.rb +0 -83
- data/features/step_definitions/audio_steps.rb +0 -27
- data/features/step_definitions/bold_steps.rb +0 -12
- data/features/step_definitions/button_steps.rb +0 -48
- data/features/step_definitions/canvas_steps.rb +0 -15
- data/features/step_definitions/check_box_steps.rb +0 -35
- data/features/step_definitions/div_steps.rb +0 -19
- data/features/step_definitions/element_steps.rb +0 -294
- data/features/step_definitions/file_field_steps.rb +0 -19
- data/features/step_definitions/form_steps.rb +0 -19
- data/features/step_definitions/frames_steps.rb +0 -159
- data/features/step_definitions/generic_element_steps.rb +0 -31
- data/features/step_definitions/gxt_table_steps.rb +0 -53
- data/features/step_definitions/headings_steps.rb +0 -12
- data/features/step_definitions/hidden_field_steps.rb +0 -27
- data/features/step_definitions/image_steps.rb +0 -27
- data/features/step_definitions/indexed_property_steps.rb +0 -163
- data/features/step_definitions/italic_steps.rb +0 -12
- data/features/step_definitions/javascript_steps.rb +0 -53
- data/features/step_definitions/label_steps.rb +0 -19
- data/features/step_definitions/link_steps.rb +0 -40
- data/features/step_definitions/list_item_steps.rb +0 -19
- data/features/step_definitions/modal_dialog_steps.rb +0 -62
- data/features/step_definitions/multi_elements_steps.rb +0 -554
- data/features/step_definitions/nested_elements_steps.rb +0 -212
- data/features/step_definitions/ordered_list_steps.rb +0 -23
- data/features/step_definitions/page_level_actions_steps.rb +0 -135
- data/features/step_definitions/page_traversal_steps.rb +0 -8
- data/features/step_definitions/paragraph_steps.rb +0 -28
- data/features/step_definitions/radio_button_group_steps.rb +0 -36
- data/features/step_definitions/radio_button_steps.rb +0 -27
- data/features/step_definitions/section_steps.rb +0 -277
- data/features/step_definitions/select_list_steps.rb +0 -65
- data/features/step_definitions/span_steps.rb +0 -19
- data/features/step_definitions/table_cell_steps.rb +0 -15
- data/features/step_definitions/table_row_steps.rb +0 -23
- data/features/step_definitions/table_steps.rb +0 -70
- data/features/step_definitions/text_area_steps.rb +0 -35
- data/features/step_definitions/text_field_steps.rb +0 -35
- data/features/step_definitions/unordered_list_steps.rb +0 -23
- data/features/step_definitions/video_steps.rb +0 -45
- data/features/support/ajax_text_environment.rb +0 -26
- data/features/support/audio_video_page.rb +0 -24
- data/features/support/env.rb +0 -8
- data/features/support/hooks.rb +0 -8
- data/features/support/page.rb +0 -373
- data/features/support/persistent_browser.rb +0 -70
- data/features/support/targets/firefox14_osx.rb +0 -6
- data/features/support/targets/firefox14_windows7.rb +0 -6
- data/features/support/url_helper.rb +0 -61
- data/features/table.feature +0 -122
- data/features/table_cell.feature +0 -45
- data/features/table_row.feature +0 -43
- data/features/text_area.feature +0 -51
- data/features/text_field.feature +0 -70
- data/features/unordered_list.feature +0 -56
- data/features/video.feature +0 -69
- data/spec/page-object/accessors_spec.rb +0 -40
- data/spec/page-object/element_locators_spec.rb +0 -1144
- data/spec/page-object/elements/area_spec.rb +0 -45
- data/spec/page-object/elements/bold_spec.rb +0 -29
- data/spec/page-object/elements/button_spec.rb +0 -64
- data/spec/page-object/elements/canvas_spec.rb +0 -41
- data/spec/page-object/elements/check_box_spec.rb +0 -49
- data/spec/page-object/elements/div_spec.rb +0 -28
- data/spec/page-object/elements/element_spec.rb +0 -196
- data/spec/page-object/elements/file_field_spec.rb +0 -39
- data/spec/page-object/elements/form_spec.rb +0 -28
- data/spec/page-object/elements/heading_spec.rb +0 -48
- data/spec/page-object/elements/hidden_field_spec.rb +0 -28
- data/spec/page-object/elements/image_spec.rb +0 -66
- data/spec/page-object/elements/italic_spec.rb +0 -29
- data/spec/page-object/elements/label_spec.rb +0 -29
- data/spec/page-object/elements/link_spec.rb +0 -49
- data/spec/page-object/elements/list_item_spec.rb +0 -29
- data/spec/page-object/elements/media_spec.rb +0 -63
- data/spec/page-object/elements/nested_element_spec.rb +0 -254
- data/spec/page-object/elements/option_spec.rb +0 -11
- data/spec/page-object/elements/ordered_list_spec.rb +0 -78
- data/spec/page-object/elements/paragraph_spec.rb +0 -27
- data/spec/page-object/elements/select_list_spec.rb +0 -142
- data/spec/page-object/elements/selenium/radio_button_spec.rb +0 -44
- data/spec/page-object/elements/selenium/text_field_spec.rb +0 -49
- data/spec/page-object/elements/selenium_element_spec.rb +0 -218
- data/spec/page-object/elements/span_spec.rb +0 -26
- data/spec/page-object/elements/table_cell_spec.rb +0 -21
- data/spec/page-object/elements/table_row_spec.rb +0 -70
- data/spec/page-object/elements/table_spec.rb +0 -98
- data/spec/page-object/elements/text_area_spec.rb +0 -39
- data/spec/page-object/elements/unordered_list_spec.rb +0 -77
- data/spec/page-object/elements/video_spec.rb +0 -33
- data/spec/page-object/elements/watir_element_spec.rb +0 -193
- data/spec/page-object/javascript_framework_facade_spec.rb +0 -61
- data/spec/page-object/loads_platform_spec.rb +0 -53
- data/spec/page-object/page-object_spec.rb +0 -435
- data/spec/page-object/page_factory_spec.rb +0 -238
- data/spec/page-object/page_populator_spec.rb +0 -122
- data/spec/page-object/page_section_spec.rb +0 -80
- data/spec/page-object/platforms/selenium_webdriver/selenium_page_object_spec.rb +0 -68
- data/spec/page-object/platforms/selenium_webdriver_spec.rb +0 -29
- data/spec/page-object/platforms/watir_webdriver/watir_page_object_spec.rb +0 -29
- data/spec/page-object/platforms/watir_webdriver_spec.rb +0 -9
- data/spec/page-object/selenium_accessors_spec.rb +0 -628
- data/spec/page-object/watir_accessors_spec.rb +0 -1191
- data/spec/page-object/widget_spec.rb +0 -226
- data/spec/spec_helper.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83096c48419028baf9d916c2f0c6baca18d821df
|
4
|
+
data.tar.gz: 96c9fac57d4606967a33a73780d638ad246ef3d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dac077be6fe9e3e6a32ebc5357618ad811d6f7702787cceb0741fa9f9e279ee49c9882ee7f611b0260e852e14b1a6c4640e285f9af609ad49ae9156df3000fb3
|
7
|
+
data.tar.gz: 7e90d74a30d201603688e54779c2779a081b5f57154a1ceb87b623610c261eadf8a3f092ba09487c46039508c02736445792906db1ae49cf68aac719d2e89415
|
data/.travis.yml
CHANGED
@@ -1,15 +1,25 @@
|
|
1
|
-
sudo:
|
2
|
-
|
3
|
-
cache: bundler
|
1
|
+
sudo: required
|
2
|
+
dist: trusty
|
4
3
|
rvm:
|
5
|
-
- 2.
|
6
|
-
- 2.1
|
7
|
-
|
8
|
-
- jruby-19mode
|
9
|
-
|
4
|
+
- 2.2.5
|
5
|
+
- 2.3.1
|
6
|
+
cache: bundler
|
10
7
|
before_script:
|
11
|
-
|
12
|
-
|
8
|
+
- export CHROME_BIN=/usr/bin/google-chrome
|
9
|
+
- export DISPLAY=:99.0
|
10
|
+
- sh -e /etc/init.d/xvfb start
|
11
|
+
- sudo apt-get update
|
12
|
+
- sudo apt-get install -y libappindicator1 fonts-liberation
|
13
|
+
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
14
|
+
- sudo dpkg -i google-chrome*.deb
|
15
|
+
- CHROMEDRIVER_VERSION=$(curl -s http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
|
16
|
+
- curl -L -O "http://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip"
|
17
|
+
- unzip chromedriver_linux64.zip
|
18
|
+
- chmod +x chromedriver
|
19
|
+
- sudo mv chromedriver /usr/local/bin
|
13
20
|
|
14
|
-
script:
|
15
|
-
|
21
|
+
script: bundle exec rake $RAKE_TASK
|
22
|
+
env:
|
23
|
+
- RAKE_TASK=spec
|
24
|
+
- RAKE_TASK=features:watir_webdriver WATIR_BRANCH=master
|
25
|
+
- RAKE_TASK=features:selenium_webdriver
|
data/ChangeLog
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
Version 1.2.1 / 2016-11-11
|
2
|
+
* Enhancements
|
3
|
+
* Added numerous missing element types
|
4
|
+
* Support for Selenium 3 (Thanks Titus Fortner)
|
5
|
+
* Added new generated method for Image - (name)_loaded? (Thanks joesho112358)
|
6
|
+
* Added CSS support for Watir (Thanks Titus Fortner)
|
7
|
+
* Added two new methods that check without throwing exception
|
8
|
+
- check_visible
|
9
|
+
- check_exists
|
10
|
+
|
1
11
|
Version 1.2.0 / 2016-6-15
|
2
12
|
* Enhancements
|
3
13
|
* Added array methods to section collections (Thanks Cohen Carlisle)
|
data/Gemfile
CHANGED
@@ -2,8 +2,6 @@ source "http://rubygems.org"
|
|
2
2
|
|
3
3
|
# adding rake so travis-ci will build properly
|
4
4
|
gem 'rake'
|
5
|
-
gem 'fuubar', '>= 2.0.0'
|
6
|
-
gem 'fuubar-cucumber', '>= 0.0.22'
|
7
5
|
gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
|
8
6
|
gem 'growl'
|
9
7
|
gem 'guard-rspec'
|
@@ -12,5 +10,9 @@ gem 'guard-cucumber'
|
|
12
10
|
gem 'net-http-persistent'
|
13
11
|
gem 'coveralls', require: false
|
14
12
|
|
13
|
+
if ENV['WATIR_BRANCH']
|
14
|
+
gem 'watir', :git => 'https://github.com/watir/watir.git', :branch => ENV['WATIR_BRANCH']
|
15
|
+
end
|
16
|
+
|
15
17
|
|
16
18
|
gemspec
|
data/Guardfile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
4
|
|
5
|
-
guard :rspec, cmd: 'rspec --color --format
|
5
|
+
guard :rspec, cmd: 'rspec --color --format documentation' do
|
6
6
|
watch(%r{^spec/.+_spec\.rb$})
|
7
7
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
8
8
|
watch(%r{^lib/page-object/platforms/(.+)/.+\.rb$}) do |m|
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/cheezy/page-object/badge.svg?nocache)](https://coveralls.io/r/cheezy/page-object)
|
6
6
|
|
7
7
|
|
8
|
-
A simple gem that assists in creating flexible page objects for testing browser based applications. The goal is to facilitate creating abstraction layers in your tests to decouple the tests from the item they are testing and to provide a simple interface to the elements on a page. It works with both watir
|
8
|
+
A simple gem that assists in creating flexible page objects for testing browser based applications. The goal is to facilitate creating abstraction layers in your tests to decouple the tests from the item they are testing and to provide a simple interface to the elements on a page. It works with both watir and selenium-webdriver.
|
9
9
|
|
10
10
|
## Documentation
|
11
11
|
|
@@ -80,7 +80,7 @@ login_page.login_with 'cheezy', 'secret'
|
|
80
80
|
````
|
81
81
|
|
82
82
|
### Creating your page object
|
83
|
-
page-object supports both [watir
|
83
|
+
page-object supports both [watir](https://github.com/watir/watir) and [selenium-webdriver](http://seleniumhq.org/docs/03_webdriver.html). The one used will be determined by which driver you pass into the constructor of your page object. The page object can be created like this:
|
84
84
|
|
85
85
|
````ruby
|
86
86
|
browser = Watir::Browser.new :firefox
|
@@ -196,7 +196,7 @@ module PageObject
|
|
196
196
|
# @param [Hash] identifier how we find a text field. You can use a multiple parameters
|
197
197
|
# by combining of any of the following except xpath. The valid keys are:
|
198
198
|
# * :class => Watir and Selenium
|
199
|
-
# * :css => Selenium
|
199
|
+
# * :css => Watir and Selenium
|
200
200
|
# * :id => Watir and Selenium
|
201
201
|
# * :index => Watir and Selenium
|
202
202
|
# * :label => Watir and Selenium
|
@@ -232,7 +232,7 @@ module PageObject
|
|
232
232
|
# @param [Hash] identifier how we find a hidden field. You can use a multiple parameters
|
233
233
|
# by combining of any of the following except xpath. The valid keys are:
|
234
234
|
# * :class => Watir and Selenium
|
235
|
-
# * :css => Selenium
|
235
|
+
# * :css => Watir and Selenium
|
236
236
|
# * :id => Watir and Selenium
|
237
237
|
# * :index => Watir and Selenium
|
238
238
|
# * :name => Watir and Selenium
|
@@ -264,7 +264,7 @@ module PageObject
|
|
264
264
|
# @param [Hash] identifier how we find a text area. You can use a multiple parameters
|
265
265
|
# by combining of any of the following except xpath. The valid keys are:
|
266
266
|
# * :class => Watir and Selenium
|
267
|
-
# * :css => Selenium
|
267
|
+
# * :css => Watir and Selenium
|
268
268
|
# * :id => Watir and Selenium
|
269
269
|
# * :index => Watir and Selenium
|
270
270
|
# * :name => Watir and Selenium
|
@@ -300,7 +300,7 @@ module PageObject
|
|
300
300
|
# @param [Hash] identifier how we find a select list. You can use a multiple parameters
|
301
301
|
# by combining of any of the following except xpath. The valid keys are:
|
302
302
|
# * :class => Watir and Selenium
|
303
|
-
# * :css => Selenium
|
303
|
+
# * :css => Watir and Selenium
|
304
304
|
# * :id => Watir and Selenium
|
305
305
|
# * :index => Watir and Selenium
|
306
306
|
# * :name => Watir and Selenium
|
@@ -376,7 +376,7 @@ module PageObject
|
|
376
376
|
# @param [Hash] identifier how we find a checkbox. You can use a multiple parameters
|
377
377
|
# by combining of any of the following except xpath. The valid keys are:
|
378
378
|
# * :class => Watir and Selenium
|
379
|
-
# * :css => Selenium
|
379
|
+
# * :css => Watir and Selenium
|
380
380
|
# * :id => Watir and Selenium
|
381
381
|
# * :index => Watir and Selenium
|
382
382
|
# * :name => Watir and Selenium
|
@@ -416,7 +416,7 @@ module PageObject
|
|
416
416
|
# @param [Hash] identifier how we find a radio button. You can use a multiple parameters
|
417
417
|
# by combining of any of the following except xpath. The valid keys are:
|
418
418
|
# * :class => Watir and Selenium
|
419
|
-
# * :css => Selenium
|
419
|
+
# * :css => Watir and Selenium
|
420
420
|
# * :id => Watir and Selenium
|
421
421
|
# * :index => Watir and Selenium
|
422
422
|
# * :name => Watir and Selenium
|
@@ -591,7 +591,7 @@ module PageObject
|
|
591
591
|
# @param [Hash] identifier how we find a table. You can use a multiple parameters
|
592
592
|
# by combining of any of the following except xpath. The valid keys are:
|
593
593
|
# * :class => Watir and Selenium
|
594
|
-
# * :css => Selenium
|
594
|
+
# * :css => Watir and Selenium
|
595
595
|
# * :id => Watir and Selenium
|
596
596
|
# * :index => Watir and Selenium
|
597
597
|
# * :name => Watir and Selenium
|
@@ -625,7 +625,7 @@ module PageObject
|
|
625
625
|
# * :name => Watir and Selenium
|
626
626
|
# * :text => Watir and Selenium
|
627
627
|
# * :xpath => Watir and Selenium
|
628
|
-
# * :css => Selenium
|
628
|
+
# * :css => Watir and Selenium
|
629
629
|
# @param optional block to be invoked when element method is called
|
630
630
|
#
|
631
631
|
def cell(name, identifier={:index => 0}, &block)
|
@@ -668,19 +668,20 @@ module PageObject
|
|
668
668
|
end
|
669
669
|
|
670
670
|
#
|
671
|
-
# adds
|
672
|
-
# check the image
|
671
|
+
# adds three methods - one to retrieve the image element, another to
|
672
|
+
# check the load status of the image, and another to check the
|
673
|
+
# image's existence.
|
673
674
|
#
|
674
675
|
# @example
|
675
676
|
# image(:logo, :id => 'logo')
|
676
|
-
# # will generate 'logo_element' and 'logo?' methods
|
677
|
+
# # will generate 'logo_element', 'logo_loaded?', and 'logo?' methods
|
677
678
|
#
|
678
679
|
# @param [Symbol] the name used for the generated methods
|
679
680
|
# @param [Hash] identifier how we find an image. You can use a multiple parameters
|
680
681
|
# by combining of any of the following except xpath. The valid keys are:
|
681
682
|
# * :alt => Watir and Selenium
|
682
683
|
# * :class => Watir and Selenium
|
683
|
-
# * :css => Selenium
|
684
|
+
# * :css => Watir and Selenium
|
684
685
|
# * :id => Watir and Selenium
|
685
686
|
# * :index => Watir and Selenium
|
686
687
|
# * :name => Watir and Selenium
|
@@ -690,6 +691,10 @@ module PageObject
|
|
690
691
|
#
|
691
692
|
def image(name, identifier={:index => 0}, &block)
|
692
693
|
standard_methods(name, identifier, 'image_for', &block)
|
694
|
+
define_method("#{name}_loaded?") do
|
695
|
+
return platform.image_loaded_for identifier.clone unless block_given?
|
696
|
+
self.send("#{name}_element").loaded?
|
697
|
+
end
|
693
698
|
end
|
694
699
|
alias_method :img, :image
|
695
700
|
|
@@ -706,7 +711,7 @@ module PageObject
|
|
706
711
|
# by combining of any of the following except xpath. The valid keys are:
|
707
712
|
# * :action => Watir and Selenium
|
708
713
|
# * :class => Watir and Selenium
|
709
|
-
# * :css => Selenium
|
714
|
+
# * :css => Watir and Selenium
|
710
715
|
# * :id => Watir and Selenium
|
711
716
|
# * :index => Watir and Selenium
|
712
717
|
# * :xpath => Watir and Selenium
|
@@ -759,7 +764,7 @@ module PageObject
|
|
759
764
|
# @param [Hash] identifier how we find an unordered list. You can use a multiple parameters
|
760
765
|
# by combining of any of the following except xpath. The valid keys are:
|
761
766
|
# * :class => Watir and Selenium
|
762
|
-
# * :css => Selenium
|
767
|
+
# * :css => Watir and Selenium
|
763
768
|
# * :id => Watir and Selenium
|
764
769
|
# * :index => Watir and Selenium
|
765
770
|
# * :name => Watir and Selenium
|
@@ -788,7 +793,7 @@ module PageObject
|
|
788
793
|
# @param [Hash] identifier how we find an ordered list. You can use a multiple parameters
|
789
794
|
# by combining of any of the following except xpath. The valid keys are:
|
790
795
|
# * :class => Watir and Selenium
|
791
|
-
# * :css => Selenium
|
796
|
+
# * :css => Watir and Selenium
|
792
797
|
# * :id => Watir and Selenium
|
793
798
|
# * :index => Watir and Selenium
|
794
799
|
# * :name => Watir and Selenium
|
@@ -1006,7 +1011,7 @@ module PageObject
|
|
1006
1011
|
# @param [Hash] identifier how we find a file_field. You can use a multiple parameters
|
1007
1012
|
# by combining of any of the following except xpath. The valid keys are:
|
1008
1013
|
# * :class => Watir and Selenium
|
1009
|
-
# * :css => Selenium
|
1014
|
+
# * :css => Watir and Selenium
|
1010
1015
|
# * :id => Watir and Selenium
|
1011
1016
|
# * :index => Watir and Selenium
|
1012
1017
|
# * :name => Watir and Selenium
|
@@ -1215,7 +1220,7 @@ module PageObject
|
|
1215
1220
|
# @param [Hash] identifier how we find a svg. You can use a multiple parameters
|
1216
1221
|
# by combining of any of the following except xpath. The valid keys are:
|
1217
1222
|
# * :class => Watir and Selenium
|
1218
|
-
# * :css => Selenium
|
1223
|
+
# * :css => Watir and Selenium
|
1219
1224
|
# * :id => Watir and Selenium
|
1220
1225
|
# * :index => Watir and Selenium
|
1221
1226
|
# * :name => Watir and Selenium
|
@@ -1240,7 +1245,7 @@ module PageObject
|
|
1240
1245
|
# @param [Hash] identifier how we find an element. You can use a multiple parameters
|
1241
1246
|
# by combining of any of the following except xpath. The valid keys are:
|
1242
1247
|
# * :class => Watir and Selenium
|
1243
|
-
# * :css => Selenium
|
1248
|
+
# * :css => Watir and Selenium
|
1244
1249
|
# * :id => Watir and Selenium
|
1245
1250
|
# * :index => Watir and Selenium
|
1246
1251
|
# * :name => Watir and Selenium
|
@@ -1248,21 +1253,25 @@ module PageObject
|
|
1248
1253
|
# @param optional block to be invoked when element method is called
|
1249
1254
|
#
|
1250
1255
|
def element(name, tag=:element, identifier={ :index => 0 }, &block)
|
1251
|
-
# default tag to :element
|
1252
|
-
#
|
1253
|
-
# element 'button', css: 'some css'
|
1254
1256
|
#
|
1255
|
-
#
|
1256
|
-
#
|
1257
|
-
# element 'button', :element, css: 'some css'
|
1257
|
+
# sets tag as element if not defined
|
1258
1258
|
#
|
1259
1259
|
if tag.is_a?(Hash)
|
1260
1260
|
identifier = tag
|
1261
1261
|
tag = :element
|
1262
1262
|
end
|
1263
1263
|
|
1264
|
+
standard_methods(name, identifier, 'element_for', &block)
|
1265
|
+
|
1264
1266
|
define_method("#{name}") do
|
1265
|
-
self.send("#{name}_element")
|
1267
|
+
element = self.send("#{name}_element")
|
1268
|
+
|
1269
|
+
%w(Button TextField Radio Hidden CheckBox FileField).each do |klass|
|
1270
|
+
next unless element.element.class.to_s == "Watir::#{klass}"
|
1271
|
+
self.class.send(klass.gsub(/(.)([A-Z])/,'\1_\2').downcase, name, identifier, &block)
|
1272
|
+
return self.send name
|
1273
|
+
end
|
1274
|
+
element.text
|
1266
1275
|
end
|
1267
1276
|
define_method("#{name}_element") do
|
1268
1277
|
return call_block(&block) if block_given?
|
@@ -1271,6 +1280,24 @@ module PageObject
|
|
1271
1280
|
define_method("#{name}?") do
|
1272
1281
|
self.send("#{name}_element").exists?
|
1273
1282
|
end
|
1283
|
+
define_method("#{name}=") do |value|
|
1284
|
+
element = self.send("#{name}_element")
|
1285
|
+
|
1286
|
+
klass = case element.element
|
1287
|
+
when Watir::TextField
|
1288
|
+
'text_field'
|
1289
|
+
when Watir::TextArea
|
1290
|
+
'text_area'
|
1291
|
+
when Watir::Select
|
1292
|
+
'select_list'
|
1293
|
+
when Watir::FileField
|
1294
|
+
'file_field'
|
1295
|
+
else
|
1296
|
+
raise "Can not set a #{element.element} element with #="
|
1297
|
+
end
|
1298
|
+
self.class.send(klass, name, identifier, &block)
|
1299
|
+
self.send("#{name}=", value)
|
1300
|
+
end
|
1274
1301
|
end
|
1275
1302
|
|
1276
1303
|
#
|
@@ -1286,7 +1313,7 @@ module PageObject
|
|
1286
1313
|
# @param [Hash] identifier how we find an element. You can use a multiple parameters
|
1287
1314
|
# by combining of any of the following except xpath. The valid keys are:
|
1288
1315
|
# * :class => Watir and Selenium
|
1289
|
-
# * :css => Selenium
|
1316
|
+
# * :css => Watir and Selenium
|
1290
1317
|
# * :id => Watir and Selenium
|
1291
1318
|
# * :index => Watir and Selenium
|
1292
1319
|
# * :name => Watir and Selenium
|
@@ -1294,13 +1321,8 @@ module PageObject
|
|
1294
1321
|
# @param optional block to be invoked when element method is called
|
1295
1322
|
#
|
1296
1323
|
def elements(name, tag=:element, identifier={:index => 0}, &block)
|
1297
|
-
# default tag to :element
|
1298
|
-
#
|
1299
|
-
# elements 'button', css: 'some css'
|
1300
1324
|
#
|
1301
|
-
#
|
1302
|
-
#
|
1303
|
-
# elements 'button', :element, css: 'some css'
|
1325
|
+
# sets tag as element if not defined
|
1304
1326
|
#
|
1305
1327
|
if tag.is_a?(Hash)
|
1306
1328
|
identifier = tag
|
@@ -1325,7 +1347,7 @@ module PageObject
|
|
1325
1347
|
# @param [Hash] identifier how we find an element. You can use multiple parameters
|
1326
1348
|
# by combining of any of the following except xpath. The valid keys are:
|
1327
1349
|
# * :class => Watir and Selenium
|
1328
|
-
# * :css => Selenium
|
1350
|
+
# * :css => Watir and Selenium
|
1329
1351
|
# * :id => Watir and Selenium
|
1330
1352
|
# * :index => Watir and Selenium
|
1331
1353
|
# * :name => Watir and Selenium
|
@@ -1349,7 +1371,7 @@ module PageObject
|
|
1349
1371
|
# @param [Hash] identifier how we find an element. You can use a multiple parameters
|
1350
1372
|
# by combining of any of the following except xpath. The valid keys are:
|
1351
1373
|
# * :class => Watir and Selenium
|
1352
|
-
# * :css => Selenium
|
1374
|
+
# * :css => Watir and Selenium
|
1353
1375
|
# * :id => Watir and Selenium
|
1354
1376
|
# * :index => Watir and Selenium
|
1355
1377
|
# * :name => Watir and Selenium
|
@@ -1376,7 +1398,7 @@ module PageObject
|
|
1376
1398
|
# @param [Hash] identifier how we find an element. You can use a multiple parameters
|
1377
1399
|
# by combining of any of the following except xpath. The valid keys are:
|
1378
1400
|
# * :class => Watir and Selenium
|
1379
|
-
# * :css => Selenium
|
1401
|
+
# * :css => Watir and Selenium
|
1380
1402
|
# * :id => Watir and Selenium
|
1381
1403
|
# * :index => Watir and Selenium
|
1382
1404
|
# * :name => Watir and Selenium
|
@@ -70,6 +70,23 @@ module PageObject
|
|
70
70
|
downcase}s"
|
71
71
|
end
|
72
72
|
|
73
|
+
#
|
74
|
+
# Keeps checking until the element is visible
|
75
|
+
#
|
76
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
77
|
+
#
|
78
|
+
def check_visible(timeout=::PageObject.default_element_wait)
|
79
|
+
timed_loop(timeout) do |element|
|
80
|
+
element.visible?
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def check_exists(timeout=::PageObject.default_element_wait)
|
85
|
+
timed_loop(timeout) do |element|
|
86
|
+
element.exists?
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
73
90
|
# @private
|
74
91
|
def self.watir_identifier_for identifier
|
75
92
|
if should_build_watir_xpath(identifier)
|
@@ -245,6 +262,15 @@ module PageObject
|
|
245
262
|
|
246
263
|
private
|
247
264
|
|
265
|
+
def timed_loop(timeout)
|
266
|
+
end_time = ::Time.now + timeout
|
267
|
+
until ::Time.now > end_time
|
268
|
+
result = yield(self)
|
269
|
+
return result if result
|
270
|
+
sleep 0.5
|
271
|
+
end
|
272
|
+
false
|
273
|
+
end
|
248
274
|
|
249
275
|
def constantize_classname name
|
250
276
|
name.split("::").inject(Object) { |k,n| k.const_get(n) }
|
@@ -3,71 +3,117 @@ module PageObject
|
|
3
3
|
|
4
4
|
BASIC_ELEMENTS = [:abbr,
|
5
5
|
:address,
|
6
|
+
:animate,
|
7
|
+
:animate_motion,
|
8
|
+
:animate_transform,
|
6
9
|
:article,
|
7
10
|
:as,
|
8
11
|
:aside,
|
12
|
+
:base,
|
9
13
|
:bdi,
|
10
14
|
:bdo,
|
11
15
|
:blockquote,
|
12
16
|
:body,
|
13
17
|
:br,
|
14
18
|
:caption,
|
19
|
+
:circle,
|
15
20
|
:cite,
|
16
21
|
:code,
|
17
22
|
:col,
|
18
23
|
:colgroup,
|
19
24
|
:command,
|
25
|
+
:cursor,
|
20
26
|
:data,
|
21
27
|
:datalist,
|
22
28
|
:dd,
|
29
|
+
:defs,
|
23
30
|
:del,
|
31
|
+
:desc,
|
24
32
|
:details,
|
25
33
|
:dfn,
|
26
34
|
:dialog,
|
35
|
+
:discard,
|
27
36
|
:dl,
|
28
37
|
:dt,
|
38
|
+
:ellipse,
|
29
39
|
:em,
|
30
40
|
:embed,
|
31
41
|
:fieldset,
|
32
42
|
:figcaption,
|
33
43
|
:figure,
|
44
|
+
:font,
|
34
45
|
:footer,
|
46
|
+
:foreign_object,
|
47
|
+
:g,
|
35
48
|
:head,
|
36
49
|
:header,
|
37
50
|
:hgroup,
|
38
51
|
:hr,
|
52
|
+
:html,
|
39
53
|
:ins,
|
40
54
|
:kbd,
|
41
55
|
:keygen,
|
42
56
|
:legend,
|
57
|
+
:line,
|
58
|
+
:linear_gradient,
|
59
|
+
:main,
|
43
60
|
:map,
|
44
61
|
:mark,
|
62
|
+
:marker,
|
45
63
|
:menu,
|
64
|
+
:menuitem,
|
65
|
+
:mesh_gradient,
|
66
|
+
:mesh_patch,
|
67
|
+
:mesh_row,
|
46
68
|
:meta,
|
69
|
+
:metadata,
|
47
70
|
:meter,
|
71
|
+
:mpath,
|
48
72
|
:nav,
|
49
73
|
:noscript,
|
50
74
|
:object,
|
51
75
|
:optgroup,
|
52
76
|
:output,
|
77
|
+
:p,
|
53
78
|
:param,
|
79
|
+
:path,
|
80
|
+
:pattern,
|
81
|
+
:polygon,
|
82
|
+
:polyline,
|
54
83
|
:pre,
|
55
84
|
:progress,
|
85
|
+
:q,
|
86
|
+
:radial_gradient,
|
87
|
+
:rect,
|
56
88
|
:rp,
|
57
89
|
:rt,
|
58
90
|
:ruby,
|
91
|
+
:s,
|
59
92
|
:samp,
|
93
|
+
:script,
|
60
94
|
:section,
|
95
|
+
:set,
|
61
96
|
:small,
|
97
|
+
:source,
|
98
|
+
:stop,
|
62
99
|
:strong,
|
63
100
|
:style,
|
64
101
|
:sub,
|
65
102
|
:summary,
|
66
103
|
:sup,
|
104
|
+
:switch,
|
105
|
+
:symbol,
|
106
|
+
:template,
|
107
|
+
:text_path,
|
108
|
+
:thread,
|
67
109
|
:time,
|
68
110
|
:title,
|
69
111
|
:track,
|
112
|
+
:tspan,
|
113
|
+
:u,
|
114
|
+
:use,
|
70
115
|
:var,
|
116
|
+
:view,
|
71
117
|
:wbr]
|
72
118
|
|
73
119
|
|