druid-ts 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +21 -2
- data/Gemfile +1 -1
- data/druid.gemspec +3 -3
- data/features/element.feature +0 -5
- data/features/frames.feature +4 -0
- data/features/html/static_elements.html +11 -0
- data/features/populate_page_with.feature +25 -0
- data/features/select_list.feature +1 -0
- data/features/step_definations/audio_steps.rb +1 -1
- data/features/step_definations/element_steps.rb +0 -4
- data/features/step_definations/frame_steps.rb +35 -0
- data/features/step_definations/populate_page_with_steps.rb +3 -0
- data/features/step_definations/select_list_steps.rb +4 -0
- data/features/step_definations/table_steps.rb +19 -0
- data/features/support/page.rb +2 -0
- data/features/table.feature +21 -0
- data/lib/druid.rb +0 -1
- data/lib/druid/assist.rb +8 -5
- data/lib/druid/elements/area.rb +0 -20
- data/lib/druid/elements/check_box.rb +0 -20
- data/lib/druid/elements/element.rb +73 -64
- data/lib/druid/elements/file_field.rb +0 -6
- data/lib/druid/elements/hidden_field.rb +0 -4
- data/lib/druid/elements/image.rb +0 -7
- data/lib/druid/elements/media.rb +0 -34
- data/lib/druid/elements/ordered_list.rb +8 -21
- data/lib/druid/elements/radio_button.rb +0 -13
- data/lib/druid/elements/select_list.rb +2 -11
- data/lib/druid/elements/table.rb +41 -16
- data/lib/druid/elements/table_row.rb +21 -17
- data/lib/druid/elements/text_area.rb +0 -7
- data/lib/druid/elements/text_field.rb +0 -7
- data/lib/druid/elements/unordered_list.rb +9 -22
- data/lib/druid/javascript_framework_facade.rb +1 -1
- data/lib/druid/locator_generator.rb +153 -147
- data/lib/druid/page_populator.rb +44 -37
- data/lib/druid/version.rb +1 -1
- data/spec/druid/accessors_spec.rb +3 -3
- data/spec/druid/elements/check_box_spec.rb +0 -15
- data/spec/druid/elements/element_spec.rb +77 -78
- data/spec/druid/elements/file_field_spec.rb +0 -5
- data/spec/druid/elements/media_spec.rb +0 -49
- data/spec/druid/elements/ordered_list_spec.rb +24 -20
- data/spec/druid/elements/radio_button_spec.rb +0 -10
- data/spec/druid/elements/table_row_spec.rb +12 -12
- data/spec/druid/elements/table_spec.rb +29 -25
- data/spec/druid/elements/text_area_spec.rb +0 -4
- data/spec/druid/elements/text_field_spec.rb +0 -5
- data/spec/druid/elements/unordered_list_spec.rb +25 -20
- data/spec/druid/javascript_framework_facade_spec.rb +1 -1
- data/spec/druid/page_populator_spec.rb +34 -4
- metadata +15 -18
- data/lib/druid/core_ext/string.rb +0 -5
- data/spec/druid/elements/area_spec.rb +0 -25
- data/spec/druid/elements/canvas_spec.rb +0 -19
- data/spec/druid/elements/video_spec.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a37878faec17d55dc5e46271488aa642a92a3f00
|
4
|
+
data.tar.gz: cf7cfade0356638ddd7e22c310789f33c4cd60a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 351a66a011905ed2722a268153d9d9dbfbca1a276a51cbb2681a831823fa4c93785e193983aa8aa7831d9912883c2f160d8eeb55e15840206345b93064c635e9
|
7
|
+
data.tar.gz: 56f28412001a34ad9c26dd3d43fff4141bad3774b567203b03dfdc22d48f5c715137b9cee773d303bf34914f7c360edf92c1d881ffb7b9b5c113cb11f198918a
|
data/ChangeLog
CHANGED
@@ -1,6 +1,25 @@
|
|
1
|
-
=== 2017-
|
1
|
+
=== Version 1.2.5/ 2017-10-16
|
2
|
+
* Enhancements
|
3
|
+
* Added the ability to get the values of a table column
|
4
|
+
* Added the ability to populate sections with a nested entry from data_magic
|
5
|
+
=== 2017-10-15
|
6
|
+
* Enhancements
|
7
|
+
* Added the preceding_sibling method to Element
|
8
|
+
* Added the following_sibling method to Element
|
9
|
+
* Added the siblings method to Element
|
10
|
+
* Added the children method to Element
|
11
|
+
* Added the preceding_siblings method to Element
|
12
|
+
* Added the following_siblings method to Element
|
13
|
+
* Fixes
|
14
|
+
* Fixed issue that occurred when things were moved around in Watir 6.8
|
15
|
+
=== 2017-10-12
|
16
|
+
* Enhancements
|
17
|
+
* Fix bug in integration of frames and sections
|
18
|
+
* delegate select list text method directly to watir
|
19
|
+
* optimize the way to generate a array of symbol
|
20
|
+
=== Version 1.2.4/ 2017-06-12
|
2
21
|
* Add cookies method to druid
|
3
|
-
=== 2017-04-24
|
22
|
+
=== Version 1.2.3/ 2017-04-24
|
4
23
|
* Removed all direct delegateds. Now relies on method_missing to call Watir methods.
|
5
24
|
* You may have to change RSpec matchers to use method instead of predicate.
|
6
25
|
=== Version 1.2.2/ 2017/02-14
|
data/Gemfile
CHANGED
data/druid.gemspec
CHANGED
@@ -18,11 +18,11 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f)}
|
20
20
|
s.require_paths = ["lib"]
|
21
|
-
s.add_dependency "watir", "~> 6.
|
21
|
+
s.add_dependency "watir", "~> 6.8"
|
22
22
|
s.add_dependency "page_navigation", ">= 0.10"
|
23
23
|
|
24
|
-
s.add_development_dependency "rspec", "
|
25
|
-
s.add_development_dependency "cucumber", "
|
24
|
+
s.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
s.add_development_dependency "cucumber", "~> 2.0"
|
26
26
|
s.add_development_dependency "rack", ">= 1.0"
|
27
27
|
s.add_development_dependency "net-http-persistent", "~> 3.0"
|
28
28
|
|
data/features/element.feature
CHANGED
@@ -244,11 +244,6 @@ Feature: Elements
|
|
244
244
|
When I retrieve a button element
|
245
245
|
Then I should know its id is "button_id"
|
246
246
|
|
247
|
-
Scenario: Scrolling so an element is visible
|
248
|
-
When I retrieve a heading element
|
249
|
-
And I scroll the heading element into view
|
250
|
-
Then the heading element should be visible
|
251
|
-
|
252
247
|
Scenario: Expanding how we find elemnts to include non-stardard locators
|
253
248
|
When I retrieve a div using data-entity
|
254
249
|
Then I should know it exists
|
data/features/frames.feature
CHANGED
@@ -70,3 +70,7 @@ Scenario: Accessing elements within the frame using multiple identifiers
|
|
70
70
|
Given I am on the iframe elements page
|
71
71
|
When I type "page-object" into the text field for frame 2 using "multiple identifiers"
|
72
72
|
Then I should verify "page-object" is in the text field for frame 2 using "multiple identifiers"
|
73
|
+
|
74
|
+
Scenario: Frames in sections
|
75
|
+
Given I am on the frame section page
|
76
|
+
Then I should be able to access an element in the frame in the section repeatedly
|
@@ -119,6 +119,17 @@
|
|
119
119
|
</tbody>
|
120
120
|
</table>
|
121
121
|
|
122
|
+
<table id='table_with_regex' border='1'>
|
123
|
+
<tr>
|
124
|
+
<td>Price1 |</td>
|
125
|
+
<td>$420.99</td>
|
126
|
+
</tr>
|
127
|
+
<tr>
|
128
|
+
<td>Price |</td>
|
129
|
+
<td>$69.99</td>
|
130
|
+
</tr>
|
131
|
+
</table>
|
132
|
+
|
122
133
|
<form method="get" action="success.html">
|
123
134
|
<input id='button_id' name='button_name' class='button_class' type="submit" value="Click Me"/>
|
124
135
|
<input id='button_image_id' type='image' src='images/submit.gif' alt='Submit'/>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: Populate Page With
|
2
|
+
In order to quickly fill out forms on a page
|
3
|
+
A tester will use the populate_page_with method
|
4
|
+
To fill in text, select options, check boxes, and select radio buttons
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I am on the static elements page
|
8
|
+
|
9
|
+
Scenario:
|
10
|
+
When I populate the page with the data:
|
11
|
+
| text_field_id | abcDEF |
|
12
|
+
| text_area_id | abcdefghijklmnop |
|
13
|
+
| select_list_id | Test 2 |
|
14
|
+
| cb_id | check |
|
15
|
+
| butter_id | check |
|
16
|
+
| favorite_cheese | muen |
|
17
|
+
Then the text field should contain "abcDEF"
|
18
|
+
And the text area should contain "abcdefghijklmnop"
|
19
|
+
And the selected option should be "Test 2"
|
20
|
+
And the First check box should be selected
|
21
|
+
And the "Butter" radio button should be selected
|
22
|
+
And the "muen" radio button should be selected in the group
|
23
|
+
When I populate the page with the data:
|
24
|
+
| select_list_id | option3 |
|
25
|
+
Then the selected option should be "Test/Test 3"
|
@@ -73,6 +73,7 @@ Feature: Select List
|
|
73
73
|
Scenario: Clearing multiple select list
|
74
74
|
When I clear multiple select list
|
75
75
|
Then multiple select list should have no selected options
|
76
|
+
And cleared multiple select list should return nil for value
|
76
77
|
|
77
78
|
Scenario: Selecting an option by its value
|
78
79
|
When I select an option using the value "option2"
|
@@ -19,7 +19,7 @@ Then(/^I should know that the audio is paused$/) do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
Then(/^I should know that its volume is (\d+)$/) do |volume|
|
22
|
-
expect(@element.volume).to eql volume.
|
22
|
+
expect(@element.volume).to eql volume.to_f
|
23
23
|
end
|
24
24
|
|
25
25
|
Given(/^I am on the audio video page$/) do
|
@@ -135,10 +135,6 @@ Then(/^I should know the html is "(.*)"$/) do |html|
|
|
135
135
|
expect(@element.html).to eql html
|
136
136
|
end
|
137
137
|
|
138
|
-
When(/^I scroll the heading element into view$/) do
|
139
|
-
@element.scroll_into_view
|
140
|
-
end
|
141
|
-
|
142
138
|
Then(/^the heading element should be visible$/) do
|
143
139
|
expect(@element.visible?).to be true
|
144
140
|
end
|
@@ -57,6 +57,41 @@ class IFramePage
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
class FrameSectionPageSection
|
61
|
+
include Druid
|
62
|
+
|
63
|
+
paragraph :p_in_section
|
64
|
+
|
65
|
+
in_iframe(id: 'three') do |frame|
|
66
|
+
link :success, id: 'four', frame: frame
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
class FrameSectionPage
|
72
|
+
include Druid
|
73
|
+
|
74
|
+
in_frame(id: 'two') do |frame|
|
75
|
+
page_section :frame_section, FrameSectionPageSection, tag_name: 'body', frame: frame
|
76
|
+
paragraph :p_on_page, frame: frame
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
Given(/^I am on the frame section page$/) do
|
82
|
+
@page = FrameSectionPage.new(@driver)
|
83
|
+
@page.navigate_to(UrlHelper.nested_frame_elements)
|
84
|
+
end
|
85
|
+
|
86
|
+
Then(/^I should be able to access an element in the frame in the section repeatedly$/) do
|
87
|
+
expect(@page.p_on_page_element).to be_visible
|
88
|
+
expect(@page.frame_section.p_in_section_element).to be_visible
|
89
|
+
expect(@page.frame_section.success_element).to be_visible
|
90
|
+
expect(@page.frame_section.success_element.text).to eq "this link should open the page success page"
|
91
|
+
@page.frame_section.success
|
92
|
+
expect(@page.text.strip).to eq 'Success'
|
93
|
+
end
|
94
|
+
|
60
95
|
Given(/^I am on the frame elements page$/) do
|
61
96
|
@page = FramePage.new(@driver)
|
62
97
|
@page.navigate_to(UrlHelper.frame_elements)
|
@@ -85,3 +85,7 @@ end
|
|
85
85
|
Then(/^the selected option should have a value of "([^"]*)"$/) do |value|
|
86
86
|
expect(@page.select_list_id_element.selected_values[0]).to eql value
|
87
87
|
end
|
88
|
+
|
89
|
+
Then(/^cleared multiple select list should return nil for value$/) do
|
90
|
+
expect(@page.select_list_multiple).to be nil
|
91
|
+
end
|
@@ -88,3 +88,22 @@ end
|
|
88
88
|
Then(/^the table should be like the expected one$/) do |expected_table|
|
89
89
|
expect(expected_table.diff!@element.hashes).to be_nil
|
90
90
|
end
|
91
|
+
|
92
|
+
When(/^I retrieve a table element with regex characters$/) do
|
93
|
+
@element = @page.table_with_regex_element
|
94
|
+
end
|
95
|
+
|
96
|
+
When(/^I ask for the column values for "([^"]*)"$/) do |header|
|
97
|
+
@values = @page.table_id_element.column_values(header)
|
98
|
+
end
|
99
|
+
|
100
|
+
Then(/^I should receive:$/) do |table|
|
101
|
+
expect(@values.size).to eql 2
|
102
|
+
table.hashes.each do |hsh|
|
103
|
+
expect(@values).to include hsh['values']
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
When(/^I ask for the column values for column (\d+)$/) do |index|
|
108
|
+
@values = @page.table_id_element.column_values(index.to_i)
|
109
|
+
end
|
data/features/support/page.rb
CHANGED
@@ -124,6 +124,8 @@ class Page
|
|
124
124
|
table(:table_css, :css => '.table_class')
|
125
125
|
table(:table_class_index, :class => "table_class", :index => 0)
|
126
126
|
table(:table_name_index, :name => "table_name", :index => 0)
|
127
|
+
table(:table_with_regex, :id => 'table_with_regex')
|
128
|
+
|
127
129
|
|
128
130
|
cell(:cell_id, :id => 'cell_id')
|
129
131
|
cell(:cell_class, :class => 'cell_class')
|
data/features/table.feature
CHANGED
@@ -104,3 +104,24 @@ Feature: Table
|
|
104
104
|
| Table | Header |
|
105
105
|
| Data1 | Data2 |
|
106
106
|
| Data3 | Data4 |
|
107
|
+
|
108
|
+
Scenario: Get rows by text with special chars
|
109
|
+
When I retrieve a table element with regex characters
|
110
|
+
Then the data for row "Price1 |" should be "Price1 |" and "$420.99"
|
111
|
+
And the data for row "rice |" should be "Price |" and "$69.99"
|
112
|
+
And the data for row "$420.99" should be "Price1 |" and "$420.99"
|
113
|
+
And the data for row "$420" should be "Price1 |" and "$420.99"
|
114
|
+
|
115
|
+
Scenario: Retrieving column values using header string
|
116
|
+
When I ask for the column values for "Header"
|
117
|
+
Then I should receive:
|
118
|
+
| values |
|
119
|
+
| Data2 |
|
120
|
+
| Data4 |
|
121
|
+
|
122
|
+
Scenario: Retrieving column values using a column number
|
123
|
+
When I ask for the column values for column 1
|
124
|
+
Then I should receive:
|
125
|
+
| values |
|
126
|
+
| Data2 |
|
127
|
+
| Data4 |
|
data/lib/druid.rb
CHANGED
data/lib/druid/assist.rb
CHANGED
@@ -63,7 +63,9 @@ module Druid
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def select_list_value_for identifier
|
66
|
-
process_call("select_list(identifier).
|
66
|
+
options = process_call("select_list(identifier).selected_options", Elements::SelectList, identifier)
|
67
|
+
return nil if options.empty?
|
68
|
+
options.first.text
|
67
69
|
end
|
68
70
|
|
69
71
|
def select_list_for identifier
|
@@ -620,8 +622,9 @@ module Druid
|
|
620
622
|
end
|
621
623
|
|
622
624
|
def parse_identifiers(identifier, element, tag_name=nil)
|
623
|
-
|
624
|
-
|
625
|
+
new_identifiers = identifier.dup
|
626
|
+
frame_identifiers = new_identifiers.delete(:frame)
|
627
|
+
return new_identifiers, frame_identifiers
|
625
628
|
end
|
626
629
|
|
627
630
|
def nested_frames(frame_identifiers)
|
@@ -632,7 +635,7 @@ module Druid
|
|
632
635
|
identifier = frame.values.first.map do |key, value|
|
633
636
|
if value.is_a?(Regexp)
|
634
637
|
":#{key} => #{value.inspect}"
|
635
|
-
elsif value.
|
638
|
+
elsif value.is_a? Integer
|
636
639
|
":#{key} => #{value}"
|
637
640
|
else
|
638
641
|
":#{key} => '#{value}'"
|
@@ -644,7 +647,7 @@ module Druid
|
|
644
647
|
end
|
645
648
|
|
646
649
|
def switch_to_default_content(frame_identifiers)
|
647
|
-
driver.wd.switch_to.default_content unless frame_identifiers.nil?
|
650
|
+
driver.browser.wd.switch_to.default_content unless frame_identifiers.nil?
|
648
651
|
end
|
649
652
|
end
|
650
653
|
end
|
data/lib/druid/elements/area.rb
CHANGED
@@ -2,26 +2,6 @@ module Druid
|
|
2
2
|
module Elements
|
3
3
|
class Area < Element
|
4
4
|
|
5
|
-
#
|
6
|
-
# Return the coordinates of the area
|
7
|
-
#
|
8
|
-
def coords
|
9
|
-
attribute(:coords)
|
10
|
-
end
|
11
|
-
|
12
|
-
#
|
13
|
-
# Return the shape of the area
|
14
|
-
#
|
15
|
-
def shape
|
16
|
-
attribute(:shape)
|
17
|
-
end
|
18
|
-
|
19
|
-
#
|
20
|
-
# Return the href of the area
|
21
|
-
#
|
22
|
-
def href
|
23
|
-
attribute(:href)
|
24
|
-
end
|
25
5
|
end
|
26
6
|
|
27
7
|
Druid::Elements.type_to_class[:area] = Druid::Elements::Area
|
@@ -2,26 +2,6 @@ module Druid
|
|
2
2
|
module Elements
|
3
3
|
class CheckBox < Element
|
4
4
|
|
5
|
-
#
|
6
|
-
# Check the checkbox
|
7
|
-
#
|
8
|
-
def check
|
9
|
-
element.set
|
10
|
-
end
|
11
|
-
|
12
|
-
#
|
13
|
-
# Uncheck the CheckBox
|
14
|
-
#
|
15
|
-
def uncheck
|
16
|
-
element.clear
|
17
|
-
end
|
18
|
-
|
19
|
-
#
|
20
|
-
# Return true if checkbox is checked
|
21
|
-
#
|
22
|
-
def checked?
|
23
|
-
element.set?
|
24
|
-
end
|
25
5
|
end
|
26
6
|
|
27
7
|
Druid::Elements.type_to_class[:checkbox] = Druid::Elements::CheckBox
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'watir/extensions/select_text'
|
2
1
|
require 'druid/nested_elements'
|
3
2
|
require 'druid/assist'
|
4
3
|
module Druid
|
@@ -32,94 +31,86 @@ module Druid
|
|
32
31
|
other.is_a? self.class and element == other.element
|
33
32
|
end
|
34
33
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
def attribute(attribute_name)
|
41
|
-
element.attribute_value attribute_name
|
42
|
-
end
|
43
|
-
|
44
|
-
#
|
45
|
-
# retrieve the class name for an element
|
46
|
-
#
|
47
|
-
def class_name
|
48
|
-
element.class_name
|
34
|
+
def check_visible(timeout=Druid.default_element_wait)
|
35
|
+
timed_loop(timeout) do |element|
|
36
|
+
element.visible?
|
37
|
+
end
|
38
|
+
# wait_until(timeout: timeout, message: "Element not visible in #{timeout} seconds", &:present?)
|
49
39
|
end
|
40
|
+
# alias_method :when_present, :check_visible
|
41
|
+
# alias_method :when_visible, :check_visible
|
50
42
|
|
51
|
-
def
|
52
|
-
element
|
43
|
+
def check_exist(timeout=Druid.default_element_wait)
|
44
|
+
timed_loop(timeout) do |element|
|
45
|
+
element.exists?
|
46
|
+
end
|
47
|
+
# wait_until(timeout: timeout, &:exist?)
|
53
48
|
end
|
54
49
|
|
55
50
|
#
|
56
|
-
#
|
51
|
+
# find the parent element
|
57
52
|
#
|
58
|
-
def
|
59
|
-
element.
|
53
|
+
def parent(opt = {})
|
54
|
+
parent = element.parent(opt)
|
55
|
+
druid_wrapper(parent)
|
60
56
|
end
|
61
57
|
|
62
58
|
#
|
63
|
-
#
|
59
|
+
# Return the element that exists at the same level of the DOM
|
60
|
+
# immediately prior to this element
|
64
61
|
#
|
65
|
-
def
|
66
|
-
element.
|
62
|
+
def preceding_sibling(opt = {})
|
63
|
+
sibling = element.preceding_sibling(opt)
|
64
|
+
druid_wrapper(sibling)
|
67
65
|
end
|
68
66
|
|
69
67
|
#
|
70
|
-
#
|
68
|
+
# Return the element that exists at the same level of the DOM
|
69
|
+
# immediately after this element
|
71
70
|
#
|
72
|
-
def
|
73
|
-
element.
|
71
|
+
def following_sibling(opt={})
|
72
|
+
sibling = element.following_sibling(opt)
|
73
|
+
druid_wrapper(sibling)
|
74
74
|
end
|
75
75
|
|
76
76
|
#
|
77
|
-
#
|
77
|
+
# Return all elements that are direct children of this element's parent
|
78
78
|
#
|
79
|
-
def
|
80
|
-
|
79
|
+
def siblings(opt={})
|
80
|
+
siblings = element.siblings(opt)
|
81
|
+
siblings.collect {|sibling| druid_wrapper(sibling)}
|
81
82
|
end
|
82
83
|
|
83
84
|
#
|
84
|
-
#
|
85
|
+
# Return all elements that are children of this element
|
85
86
|
#
|
86
|
-
def
|
87
|
-
|
87
|
+
def children(opt={})
|
88
|
+
children = element.children(opt)
|
89
|
+
children.collect {|child| druid_wrapper(child)}
|
88
90
|
end
|
89
91
|
|
90
92
|
#
|
91
|
-
#
|
93
|
+
# Return all elements that exist at the same level of the DOM
|
94
|
+
# immediately prior to this element
|
92
95
|
#
|
93
|
-
def
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
def check_visible(timeout=Druid.default_element_wait)
|
98
|
-
timed_loop(timeout) do |element|
|
99
|
-
element.visible?
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def check_exist(timeout=Druid.default_element_wait)
|
104
|
-
timed_loop(timeout) do |element|
|
105
|
-
element.exist?
|
106
|
-
end
|
96
|
+
def preceding_siblings(opt={})
|
97
|
+
siblings = element.preceding_siblings(opt)
|
98
|
+
siblings.collect {|sibling| druid_wrapper(sibling)}
|
107
99
|
end
|
108
100
|
|
109
101
|
#
|
110
|
-
#
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
102
|
+
# Return all elements that exist at the same level of the DOM
|
103
|
+
# immediately after this element
|
104
|
+
#
|
105
|
+
def following_siblings(opt={})
|
106
|
+
siblings = element.following_siblings(opt)
|
107
|
+
siblings.collect {|sibling| druid_wrapper(sibling)}
|
116
108
|
end
|
117
109
|
|
118
110
|
#
|
119
|
-
#
|
111
|
+
# Wait until the element is present
|
120
112
|
#
|
121
|
-
# @param [Integer] (defaults to: 5) seconds to wait before
|
122
|
-
# timing out
|
113
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
123
114
|
#
|
124
115
|
def when_present(timeout=Druid.default_element_wait)
|
125
116
|
element.wait_until(timeout: timeout, message: "Element not present in #{timeout} seconds", &:present?)
|
@@ -133,13 +124,13 @@ module Druid
|
|
133
124
|
# timing out
|
134
125
|
#
|
135
126
|
def when_not_present(timeout=Druid.default_element_wait)
|
136
|
-
element.wait_while(timeout: timeout, message: "Element still present
|
127
|
+
element.wait_while(timeout: timeout, message: "Element still present in #{timeout} seconds", &:present?)
|
137
128
|
end
|
138
129
|
|
139
130
|
#
|
140
|
-
#
|
131
|
+
# Wait until the element is visible
|
141
132
|
#
|
142
|
-
# @param [
|
133
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
143
134
|
#
|
144
135
|
def when_visible(timeout=Druid.default_element_wait)
|
145
136
|
when_present(timeout)
|
@@ -150,23 +141,28 @@ module Druid
|
|
150
141
|
#
|
151
142
|
# Waits until the element is not visible
|
152
143
|
#
|
153
|
-
# @param [Integer] (default to:5) seconds to wait before timing out
|
144
|
+
# @param [Integer] (default to: 5) seconds to wait before timing out
|
154
145
|
#
|
155
146
|
def when_not_visible(timeout=Druid.default_element_wait)
|
156
147
|
when_present(timeout)
|
157
148
|
element.wait_while(timeout: timeout, message: "Element still visible after #{timeout} seconds", &:visible?)
|
158
|
-
self
|
159
149
|
end
|
160
150
|
|
161
151
|
#
|
162
152
|
# Waits until the block returns true
|
163
153
|
#
|
164
|
-
# @param [Integer] (
|
154
|
+
# @param [Integer] (defaults to: 5) seconds to wait before timing out
|
155
|
+
# @param [String] the message to display if the event timeouts
|
156
|
+
# @param the block to execute when the event occurs
|
165
157
|
#
|
166
158
|
def wait_until(timeout=Druid.default_element_wait, message=nil, &block)
|
167
159
|
element.wait_until(timeout: timeout, message: message, &block)
|
168
160
|
end
|
169
161
|
|
162
|
+
def name
|
163
|
+
element.attribute(:name)
|
164
|
+
end
|
165
|
+
|
170
166
|
# @private
|
171
167
|
# delegate calls to driver element
|
172
168
|
def method_missing(*args, &block)
|
@@ -174,17 +170,30 @@ module Druid
|
|
174
170
|
element.send m, *args, &block
|
175
171
|
end
|
176
172
|
|
173
|
+
def respond_to_missing?(m,*args)
|
174
|
+
element.respond_to?(m) || super
|
175
|
+
end
|
176
|
+
|
177
|
+
protected
|
178
|
+
|
179
|
+
def druid_wrapper(object)
|
180
|
+
type = element.type if object.tag_name.to_sym == :input
|
181
|
+
cls = Druid::Elements.element_class_for(object.tag_name, type)
|
182
|
+
cls.new(object.to_subtype)
|
183
|
+
end
|
184
|
+
|
177
185
|
private
|
178
186
|
|
179
187
|
def timed_loop(timeout)
|
180
|
-
end_time = Time.now + timeout
|
181
|
-
until Time.now > end_time
|
188
|
+
end_time = ::Time.now + timeout
|
189
|
+
until ::Time.now > end_time
|
182
190
|
result = yield(self)
|
183
191
|
return result if result
|
184
192
|
sleep 0.5
|
185
193
|
end
|
186
194
|
false
|
187
195
|
end
|
196
|
+
|
188
197
|
end
|
189
198
|
end
|
190
199
|
end
|