Appium_capybara driver + Applitools integration

221 Views Asked by At

I'm using RSpec framework with capybara + eyes_selenium for visual testing, and i want to integrate mobile visual testing. i installed the appium_capybara, and it works with a remote appium server that functions as a node in my remote selenium hub.

So far it works great, I've managed to login to my iOs simulator and interact with the page. The problem is integrating this whole thing with applitools.

i'm using the gem eyes_selenium, but i can't seem to perform Eyes.open with my Appium::Capybara::Driver object, getting an exception that this driver is Unknown.

Eyes.open(app_name: 'Applitools', test_name: test_name, viewport_size: viewport_size, driver: Capybara.page.driver)

anyone managed to make it work ?

1

There are 1 best solutions below

0
On

Looking at the source for the eyes_selenium gem, the only place that error can come from is from the eyes_driver method - https://github.com/applitools/eyes.sdk.ruby/blob/master/lib/applitools/selenium/eyes.rb#L39 - which is implemented as below

def eyes_driver(driver, eyes = nil)
  if driver.respond_to? :driver_for_eyes
    driver.driver_for_eyes eyes
  elsif defined?(::Capybara::Poltergeist) && (driver.is_a? ::Capybara::Poltergeist::Driver)
    Applitools::Poltergeist::Driver.new(eyes, driver: driver)
  else
    unless driver.is_a?(Applitools::Selenium::Driver)
      Applitools::EyesLogger.warn("Unrecognized driver type: (#{driver.class.name})!")
      is_mobile_device = driver.respond_to?(:capabilities) && driver.capabilities['platformName']
      Applitools::Selenium::Driver.new(eyes, driver: driver, is_mobile_device: is_mobile_device)
    end
    raise Applitools::EyesError.new "Unknown driver #{driver}!"
  end
end

At a first glance the else section of that looks fully broken to me (why create a new instance of Applitools::Selenium::Driver just to then raise an error?). However, that leaves only a few possibilities for why it's not working for you,

  1. Appium::Capybara::Driver is not a driver type supported by the eyes_selenium gem
  2. You're not requiring the files needed to patch Appium::Capybara::Driver to be supported, such as 'applitools/capybara', although after a quick look through the eyes_selenium code I don't think it adds the driver_for_eyes method to any ancestor class of Appium::Capybara::Driver (does patch Appium::Driver though) so #1 is probably more likely.