Search code examples
rubyselenium-webdriverwatir

Ruby-Watir Warning - Selenium::WebDriver::Error::ObsoleteElementError


Hey y'all I'm getting a warning running my watir test automation code and even though it works I want to address it.

The Warning: 2020-02-12 08:35:47 WARN Selenium [DEPRECATION] Selenium::WebDriver::Error::ObsoleteElementError is deprecated. Use Selenium::WebDriver::Error::StaleElementReferenceError (ensure the driver supports W3C WebDriver specification) instead.

The offending line of code:

iframe.select(:id => 'col0').wait_until(&:present?)

from this larger snippet.

 iframe = @b.iframe(:title => /Mass Delete/)
  iframe.wait_until(&:present?)
  if iframe.present?
    iframe.link(:visible_text => /Mass Delete #{type}/).click
    iframe.select(:id => 'col0').wait_until(&:present?)
    iframe.option(:text => /Owner Alias/).select
    iframe.option(:text => 'equals').select
    iframe.text_field(:id => "fval0").set user
    iframe.button(:title => "Search").click
  else
   raise "Unable to locate the Salesforce Iframe"
end

Here's the page html:

Page Html

I've tried using different locators to interact with that element but to no avail.


Solution

  • This will be addressed in the next version of Watir - exact release date is TBD. In the short-term, you have a couple of options to hide the warning.

    Log to File

    I would suggest sending the Selenium logs to a file. This keeps it separated and still available if you happen to need it.

    Selenium::WebDriver.logger.output = 'selenium.log'
    

    Ignore Warnings

    Usually you do not need the Selenium warnings as they should get addressed by Watir changes. Therefore you could change the Selenium logger to ignore warnings:

    Selenium::WebDriver.logger.level = :error