diff --git a/rb/lib/selenium/webdriver/support/select.rb b/rb/lib/selenium/webdriver/support/select.rb index cd6f3b64f61a7..cabe96d72abce 100644 --- a/rb/lib/selenium/webdriver/support/select.rb +++ b/rb/lib/selenium/webdriver/support/select.rb @@ -258,7 +258,7 @@ def find_by_text(text) end def find_by_index(index) - options.select { |option| option.dom_attribute(:index) == index.to_s } + options.select { |option| option.property(:index) == index } end def find_by_value(value) diff --git a/rb/spec/unit/selenium/webdriver/support/select_spec.rb b/rb/spec/unit/selenium/webdriver/support/select_spec.rb index 7868bb4a9567a..a99e253dc5155 100644 --- a/rb/spec/unit/selenium/webdriver/support/select_spec.rb +++ b/rb/spec/unit/selenium/webdriver/support/select_spec.rb @@ -126,10 +126,10 @@ module Support first_option = instance_double(Element, selected?: true) second_option = instance_double(Element, selected?: false) - allow(first_option).to receive(:dom_attribute).with(:index).and_return '0' + allow(first_option).to receive(:property).with(:index).and_return 0 expect(first_option).not_to receive(:click) - allow(second_option).to receive(:dom_attribute).with(:index).and_return '1' + allow(second_option).to receive(:property).with(:index).and_return 1 expect(second_option).to receive(:click).once allow(multi_select).to receive(:find_elements) @@ -137,8 +137,8 @@ module Support .and_return([first_option, second_option]) Select.new(multi_select).select_by(:index, 1) - expect(first_option).to have_received(:dom_attribute).with(:index) - expect(second_option).to have_received(:dom_attribute).with(:index) + expect(first_option).to have_received(:property).with(:index) + expect(second_option).to have_received(:property).with(:index) expect(multi_select).to have_received(:find_elements).with(tag_name: 'option') end @@ -198,8 +198,8 @@ module Support .with(tag_name: 'option') .and_return([first_option, second_option]) - allow(first_option).to receive(:dom_attribute).with(:index).and_return('2') - allow(second_option).to receive(:dom_attribute).with(:index).and_return('1') + allow(first_option).to receive(:property).with(:index).and_return(2) + allow(second_option).to receive(:property).with(:index).and_return(1) expect(first_option).to receive(:click).once expect(second_option).not_to receive(:click)