Skip to content

Commit 5a3b372

Browse files
committed
[rb] element index is a property and not an attribute
1 parent ef41797 commit 5a3b372

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

rb/lib/selenium/webdriver/support/select.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def find_by_text(text)
258258
end
259259

260260
def find_by_index(index)
261-
options.select { |option| option.dom_attribute(:index) == index.to_s }
261+
options.select { |option| option.property(:index) == index }
262262
end
263263

264264
def find_by_value(value)

rb/spec/unit/selenium/webdriver/support/select_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,19 @@ module Support
126126
first_option = instance_double(Element, selected?: true)
127127
second_option = instance_double(Element, selected?: false)
128128

129-
allow(first_option).to receive(:dom_attribute).with(:index).and_return '0'
129+
allow(first_option).to receive(:property).with(:index).and_return 0
130130
expect(first_option).not_to receive(:click)
131131

132-
allow(second_option).to receive(:dom_attribute).with(:index).and_return '1'
132+
allow(second_option).to receive(:property).with(:index).and_return 1
133133
expect(second_option).to receive(:click).once
134134

135135
allow(multi_select).to receive(:find_elements)
136136
.with(tag_name: 'option')
137137
.and_return([first_option, second_option])
138138

139139
Select.new(multi_select).select_by(:index, 1)
140-
expect(first_option).to have_received(:dom_attribute).with(:index)
141-
expect(second_option).to have_received(:dom_attribute).with(:index)
140+
expect(first_option).to have_received(:property).with(:index)
141+
expect(second_option).to have_received(:property).with(:index)
142142
expect(multi_select).to have_received(:find_elements).with(tag_name: 'option')
143143
end
144144

@@ -198,8 +198,8 @@ module Support
198198
.with(tag_name: 'option')
199199
.and_return([first_option, second_option])
200200

201-
allow(first_option).to receive(:dom_attribute).with(:index).and_return('2')
202-
allow(second_option).to receive(:dom_attribute).with(:index).and_return('1')
201+
allow(first_option).to receive(:property).with(:index).and_return(2)
202+
allow(second_option).to receive(:property).with(:index).and_return(1)
203203

204204
expect(first_option).to receive(:click).once
205205
expect(second_option).not_to receive(:click)

0 commit comments

Comments
 (0)