我在运行ruby applitool脚本时遇到错误 -
Erro - `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.`
答案 0 :(得分:0)
似乎你以某种方式设置了一个变量$driver
。它应该被Appium用于测试。
作为快速修复尝试将$ driver明确地设置为nil(例如 - 在脚本的开头),就像这样:
$driver = nil
请注意' $'变量前的符号很重要,$driver
与driver
此外,没有必要要求selenium-webdriver',因为eyes_selenium会自动将其作为依赖