Sauce Labs 有一个特定的 :passed
选项,可用于报告测试的通过/失败状态 - ( https://saucelabs.com/docs/additional-config)。
我只是想不通如何在 Ruby 中实现这一点。
我尝试在我的类中创建一个全局变量($status
),用作:passed
值的占位符> 用于 Sauce Labs 测试。然后在拆卸期间将占位符更新为适当的值。
在这个例子中,测试总是返回Fail
在我的类(class)
$status = false
在我的设置
caps[:passed] = $status
在我的拆解
def success
$status = true
end
def error
$status = false
end
我假设 caps[:passed] = $status
是在设置 期间设置并且不能更改。
我不知道如何在作业完成后更新 :passed
状态。
最佳答案
直接来自 Sauce Labs 的示例 found here .
require 'rubygems'
require "test/unit"
require 'selenium-webdriver'
class ExampleTest < Test::Unit::TestCase
def setup
caps = Selenium::WebDriver::Remote::Capabilities.firefox
caps.version = "5"
caps.platform = :XP
caps[:name] = "Testing Selenium 2 with Ruby on Sauce"
@driver = Selenium::WebDriver.for(
:remote,
:url => "http://username-string:access-key-string@ondemand.saucelabs.com:80/wd/hub",
:desired_capabilities => caps)
end
def test_sauce
@driver.navigate.to "http://saucelabs.com/test/guinea-pig"
assert @driver.title.include?("I am a page title - Sauce Labs")
end
def teardown
@driver.quit
end
end
关于Ruby Selenium Webdriver - 配置 Sauce Labs 通过/失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22617768/