Skip to content

Commit c02115b

Browse files
committed
[rb] use property instead of attribute to test values
1 parent 030f1f6 commit c02115b

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

rb/spec/integration/selenium/webdriver/action_builder_spec.rb

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ module WebDriver
4444
input = driver.find_element(css: '#working')
4545

4646
driver.action.send_keys(input, 'abcd').perform
47-
wait.until { input.attribute(:value).length == 4 }
48-
expect(input.attribute(:value)).to eq('abcd')
47+
wait.until { input.property(:value).length == 4 }
48+
expect(input.property(:value)).to eq('abcd')
4949
end
5050

5151
it 'sends keys with multiple arguments' do
@@ -55,8 +55,8 @@ module WebDriver
5555
input.click
5656

5757
driver.action.send_keys('abcd', 'dcba').perform
58-
wait.until { input.attribute(:value).length == 8 }
59-
expect(input.attribute(:value)).to eq('abcddcba')
58+
wait.until { input.property(:value).length == 8 }
59+
expect(input.property(:value)).to eq('abcddcba')
6060
end
6161

6262
it 'sends non-ASCII keys' do
@@ -66,8 +66,8 @@ module WebDriver
6666
input.click
6767

6868
driver.action.send_keys('abcd', :left, 'a').perform
69-
wait.until { input.attribute(:value).length == 5 }
70-
expect(input.attribute(:value)).to eq('abcad')
69+
wait.until { input.property(:value).length == 5 }
70+
expect(input.property(:value)).to eq('abcad')
7171
end
7272
end
7373

@@ -81,9 +81,9 @@ module WebDriver
8181
event_input.click
8282

8383
driver.action.key_down(:shift).send_keys('ab').key_up(:shift).perform
84-
wait.until { event_input.attribute(:value).length == 2 }
84+
wait.until { event_input.property(:value).length == 2 }
8585

86-
expect(event_input.attribute(:value)).to eq('AB')
86+
expect(event_input.property(:value)).to eq('AB')
8787
expected = keylogger.text.strip
8888
expect(expected).to match(/^(focus )?keydown keydown keypress keyup keydown keypress keyup keyup$/)
8989
end
@@ -131,10 +131,10 @@ module WebDriver
131131
event_input = driver.find_element(id: 'clickField')
132132

133133
driver.action.click_and_hold(event_input).perform
134-
expect(event_input.attribute(:value)).to eq('Hello')
134+
expect(event_input.property(:value)).to eq('Hello')
135135

136136
driver.action.release_actions
137-
expect(event_input.attribute(:value)).to eq('Clicked')
137+
expect(event_input.property(:value)).to eq('Clicked')
138138
end
139139
end
140140

@@ -143,24 +143,27 @@ module WebDriver
143143
driver.navigate.to url_for('javascriptPage.html')
144144
element = driver.find_element(id: 'clickField')
145145
driver.action.click(element).perform
146-
expect(element.attribute(:value)).to eq('Clicked')
146+
expect(element.property(:value)).to eq('Clicked')
147147
end
148148

149149
it 'executes with equivalent pointer methods' do
150150
driver.navigate.to url_for('javascriptPage.html')
151151
element = driver.find_element(id: 'clickField')
152152
driver.action.move_to(element).pointer_down(:left).pointer_up(:left).perform
153-
expect(element.attribute(:value)).to eq('Clicked')
153+
expect(element.property(:value)).to eq('Clicked')
154154
end
155155
end
156156

157157
describe '#double_click' do
158+
# https://issues.chromium.org/issues/400087471
159+
before { reset_driver! if GlobalTestEnv.rbe? && GlobalTestEnv.browser == :chrome }
160+
158161
it 'presses pointer twice', except: {browser: %i[safari safari_preview]} do
159162
driver.navigate.to url_for('javascriptPage.html')
160163
element = driver.find_element(id: 'doubleClickField')
161164

162165
driver.action.double_click(element).perform
163-
expect(element.attribute(:value)).to eq('DoubleClicked')
166+
expect(element.property(:value)).to eq('DoubleClicked')
164167
end
165168

166169
it 'executes with equivalent pointer methods', except: {browser: %i[safari safari_preview]} do
@@ -171,7 +174,7 @@ module WebDriver
171174
.pointer_down(:left).pointer_up(:left)
172175
.pointer_down(:left).pointer_up(:left)
173176
.perform
174-
expect(element.attribute(:value)).to eq('DoubleClicked')
177+
expect(element.property(:value)).to eq('DoubleClicked')
175178
end
176179
end
177180

@@ -181,15 +184,15 @@ module WebDriver
181184
element = driver.find_element(id: 'doubleClickField')
182185

183186
driver.action.context_click(element).perform
184-
expect(element.attribute(:value)).to eq('ContextClicked')
187+
expect(element.property(:value)).to eq('ContextClicked')
185188
end
186189

187190
it 'executes with equivalent pointer methods' do
188191
driver.navigate.to url_for('javascriptPage.html')
189192
element = driver.find_element(id: 'doubleClickField')
190193

191194
driver.action.move_to(element).pointer_down(:right).pointer_up(:right).perform
192-
expect(element.attribute(:value)).to eq('ContextClicked')
195+
expect(element.property(:value)).to eq('ContextClicked')
193196
end
194197
end
195198

@@ -199,7 +202,7 @@ module WebDriver
199202
element = driver.find_element(id: 'clickField')
200203
driver.action.move_to(element).click.perform
201204

202-
expect(element.attribute(:value)).to eq('Clicked')
205+
expect(element.property(:value)).to eq('Clicked')
203206
end
204207

205208
it 'moves to element with offset' do
@@ -212,7 +215,7 @@ module WebDriver
212215
y_offset = (destination_rect.y - origin_rect.y).ceil
213216

214217
driver.action.move_to(origin, x_offset, y_offset).click.perform
215-
expect(destination.attribute(:value)).to eq('Clicked')
218+
expect(destination.property(:value)).to eq('Clicked')
216219
end
217220
end
218221

@@ -256,7 +259,7 @@ module WebDriver
256259
rect = element.rect
257260
driver.action.move_to_location(rect.x.ceil, rect.y.ceil).click.perform
258261

259-
expect(element.attribute(:value)).to eq('Clicked')
262+
expect(element.property(:value)).to eq('Clicked')
260263
end
261264
end
262265

rb/spec/integration/selenium/webdriver/driver_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ module WebDriver
6060

6161
it 'refreshes the page' do
6262
driver.navigate.to url_for('javascriptPage.html')
63-
sleep 1 # javascript takes too long to load
64-
driver.find_element(id: 'updatediv').click
63+
short_wait { driver.find_element(id: 'updatediv') }.click
6564
expect(driver.find_element(id: 'dynamo').text).to eq('Fish and chips!')
6665
driver.navigate.refresh
6766
wait_for_element(id: 'dynamo')

0 commit comments

Comments
 (0)