0

运行 ruby​​ applitool 脚本时出现以下错误-

错误 - `mobile_device?':未初始化的常量 Applitools::Utils::EyesSeleniumUtils::Appium (NameError)

下面是我的课-

require 'eyes_selenium'
require 'selenium-webdriver'
# Initialize the eyes SDK and set your private API key.
eyes = Applitools::Selenium::Eyes.new
eyes.api_key = 'YOUR_API_KEY'
# Open a Chrome Browser.
driver = Selenium::WebDriver.for :chrome
begin
  # Start the test and set the browser's viewport size to 800x600.
  eyes.test(app_name: 'Hello World!', test_name: 'My first Selenium Ruby test!',
            viewport_size: {width:800, height:600}, driver: driver) do
    # Navigate the browser to the "hello world!" web-site.
    driver.get 'https://applitools.com/helloworld'
    # Visual checkpoint #1.
    eyes.check_window 'Hello!'
    # Click the "Click me!".
    driver.find_element(:tag_name => 'button').click
    # Visual checkpoint #2.
    eyes.check_window 'Click!'
  end
ensure
  # Close the browser.
  driver.quit

  # If the test was aborted before eyes.close was called, ends the test as aborted.`
4

1 回答 1

0

It seems like somehow you've set a variable $driver. It is supposed to be used by Appium for its tests.

As a quick fix try to set the $driver to nil explicitly for your test (for example - at the beginning of the script), just like that:

$driver = nil

Notice that '$' sign before a variable is important, and $driver is not the same as driver

Also, it is not necessary to require 'selenium-webdriver', since it will be required automatically by eyes_selenium as a dependency

于 2018-02-07T15:59:31.363 回答