Posted over 7 years ago. Visible to the public. Linked content.

Hack-fix Selenium::WebDriver::Element#select is deprecated

In some older Capybara versions (e.g. 0.3.9), we're getting lots of deprecations warnings:

Copy
Selenium::WebDriver::Element#select is deprecated. Please use Selenium::WebDriver::Element#click and determine the current state with Selenium::WebDriver::Element#selected?

Hani-elabed on Github helps. Add this code to features/support/env.rb to remove them temporarily:

Copy
# June 30th, 2011 # a temporary hack to disable the annoying upstream warnings capybara > selenium-webdriver 0.2.2 # capybara folks know about this and are working on it. See: # http://groups.google.com/group/ruby-capybara/browse_thread/thread/2cd042848332537a/7edb1699cb314862?show_docid=7edb1699cb314862 # Remove this whole block when Capybara 1.0.1 or greater are used module Selenium module WebDriver class Element # # Select this element # def select #warn "#{self.class}#select is deprecated. Please use #{self.class}#click and determine the current state with #{self.class}#selected?" unless displayed? raise Error::ElementNotDisplayedError, "you may not select an element that is not displayed" end unless enabled? raise Error::InvalidElementStateError, "cannot select a disabled element" end unless selectable? raise Error::InvalidElementStateError, "you may only select options, radios or checkboxes" end click unless selected? end end end end

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Owner of this card:

Avatar
Dominik Schöler
Last edit:
over 7 years ago
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more