Search code examples
rubycucumberwatir-webdriver

Using the :class locator to locate multiple classes with a String value is deprecated; use an Array instead


I am working on Automation using Ruby and Cucumber Watir Webdriver framework. I updated the Ruby Gems and did a bundle install. Then I started getting a warning message as "Using the :class locator to locate multiple classes with a String value is deprecated; use an Array instead"

When this warning message was fixed, on one of my colleague's system by replacing the class values in the square brackets to make it as an array. When I took a pull from Git of the latest code which had a fix, I started getting an error message as "TypeError: expected one of [String, Regexp], got ["x-img xcp_image-cls xcpid_image x-box-item x-img-default"]:Array"

I am using the Ruby with version "ruby 2.2.6p396".

I tried with bundle install and gem updates, but nothing worked. Please guide with what can be done to resolve this issue.

My GemFile.lock content:

GEM

remote: https://rubygems.org/

specs:

archive-zip (0.7.0)

  io-like (~> 0.3.0)

builder (3.2.2)

childprocess (0.5.9)

  ffi (~> 1.0, >= 1.0.11)

chromedriver-helper (1.1.0)

  archive-zip (~> 0.7.0)

  nokogiri (~> 1.6)

cucumber (2.4.0)

  builder (>= 2.1.2)

  cucumber-core (~> 1.5.0)

  cucumber-wire (~> 0.0.1)

  diff-lcs (>= 1.1.3)

  gherkin (~> 4.0)

  multi_json (>= 1.7.5, < 2.0)

  multi_test (>= 0.1.2)

cucumber-core (1.5.0)

  gherkin (~> 4.0)

cucumber-wire (0.0.1)

data_magic (1.0)

  faker (>= 1.1.2)

  yml_reader (>= 0.6)

diff-lcs (1.2.5)

faker (1.7.1)

  i18n (~> 0.5)

ffi (1.9.14-x64-mingw32)

gherkin (4.0.0)

i18n (0.7.0)

io-like (0.3.0)

mini_portile2 (2.1.0)

multi_json (1.12.1)

multi_test (0.1.2)

net-http-persistent (2.9.4)

nokogiri (1.7.1-x64-mingw32)

  mini_portile2 (~> 2.1.0)

page-object (2.0.0)

  net-http-persistent (~> 2.9.4)

  page_navigation (>= 0.9)

  selenium-webdriver (~> 3.0)

  watir (~> 6.0)

page_navigation (0.10)

  data_magic (>= 0.22)

rake (12.0.0)

rspec (3.5.0)

  rspec-core (~> 3.5.0)

  rspec-expectations (~> 3.5.0)

  rspec-mocks (~> 3.5.0)

rspec-core (3.5.4)

  rspec-support (~> 3.5.0)

rspec-expectations (3.5.0)

  diff-lcs (>= 1.2.0, < 2.0)

  rspec-support (~> 3.5.0)

rspec-mocks (3.5.0)

  diff-lcs (>= 1.2.0, < 2.0)

  rspec-support (~> 3.5.0)

rspec-support (3.5.0)

rubyzip (1.2.0)

selenium-webdriver (3.3)

  childprocess (~> 0.5)

  rubyzip (~> 1.0)

  websocket (~> 1.0)

watir (6.0.3)

  selenium-webdriver (~> 3.3)

websocket (1.2.3)

yml_reader (0.7)

PLATFORMS

x64-mingw32

DEPENDENCIES

chromedriver-helper

cucumber

data_magic

page-object

rake

rspec

BUNDLED WITH

1.13.7


Solution

  • Locating by multiple classes was added in version 6.5. Your gem file shows you are still using version 6.0.3. Using a version earlier than 6.5 will result in the TypeError that you are seeing.

    You need to upgrade your version of Watir to 6.5 or later.