首页 > 解决方案 > 尝试通过 Appium 运行我的第一个 ruby​​ 测试

问题描述

我已成功安装 Appium 并更新了以下 ruby​​ gem:

$ gem update --system $ gem update bundler

并为 ruby​​ 安装了以下 gem:

gem 卸载 -aIx appium_lib gem install --no-rdoc --no-ri appium_lib

这是我的第一个红宝石测试:

require 'rubygems'
require 'appium_lib'

APP_PATH = appAddress 

desired_caps = {
    caps: {
        platformName:  iOS,
        platformVersion: 11.4,
        deviceName:    iPhone 7,
        app:           APP_PATH,
        automationName: XCUITest,
    },
    appium_lib: {
        sauce_username:   nil,
        sauce_access_key: nil,
        wait: 60
    }
}

# Start the driver
Appium::Driver.new(desired_caps, true).start_driver

module DataSiteOne
    module iOS

    #prints statement
    puts "Entered into this test!"

    #Quit when you're done!
    driver_quit
    puts "First Tests Succeeded!"

    end
end

从终端启动 appium 然后运行我的第一个 ruby​​ 测试后,我收到以下错误消息。

require 'rubygems'
        ^^^^^^^^^^

SyntaxError: Unexpected string
    at new Script (vm.js:74:7)
    at createScript (vm.js:246:10)
    at Object.runInThisContext (vm.js:298:10)
    at Module._compile (internal/modules/cjs/loader.js:670:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
    at startup (internal/bootstrap/node.js:238:19)

标签: appiumappium-ios

解决方案


最初我用 javascript 编写了我的测试,因此我使用了以下命令:

节点“你的项目名称”

在终端中启动 appium 后,运行以下命令来运行您的 ruby​​ 测试文件: ruby​​ "fileName"


推荐阅读