我在一台名为 machineA 的 Windows 7 机器上安装了 jenkins 主节点和 testLink。 我已经通过 Java Web Start (JNLP) 在名为 machineB 的 Windows Server 2003 上安装了 Ruby 1.8.7、watir 1.7.1、ci_reporter 1.8.4、测试单元 2.5.4、rake 10.0.3、jenkins 从节点。
该项目的目标是从 machineA 开始构建,之后,jenkins slave 将在 machineB 上执行 ruby 测试(使用 watir,因此使用 ie navigator)并在 machineA 上发送报告(由 testLink 读取)。
我在 jenkins 主节点上的作业配置(在机器 A 上):
restrict where this project can be run --> machineB
svn --> url --> svn://serverSVN/project/trunk
build --> invoke testlink --> testLink cfg --> TestLink Version --> testlink 1.9.3
Test Project Name --> my project
Test Plan Name --> my testPlan
Build Name --> watirTest-$BUILD_NUMBER
Custom Fields --> watir
testExecution --> Single Build Steps --> execute windows batch cmd --> rake test CI_REPORTS=results
results seeking strategy --> include pattern --> results/*.xml
key custom field --> watir
post-action-build --> publish junit reports --> results/*.xml
这里是一个测试,我将以两种不同的方式执行(在机器 B 的本地,以及机器 A 的 Jenkins)。
require 'rubygems'
require 'watir'
require 'test/unit'
require 'ci/reporter/rake/test_unit_loader'
include Watir
class ModifierLocalisation < Test::Unit::TestCase
def test_me
ie = Watir::IE.new
ie.goto("http://ipMachine/shopA/")
assert(ie.text.include?("Identification"))
end
end
当我在本地 machineB 上执行测试时,测试通过了,所以这里是控制台输出:
** Invoke test (first_time)
** Execute test
E:/Ruby/bin/ruby.exe test/modifierLocalisation.rb
Loaded suite test/modifierLocalisation
Started
.
Finished in 2.140625 seconds.
1 tests, 1 assertions, 1 failures, 0 errors
但是当我在 machineA 上使用 jenkins 执行测试时,测试失败,(但是报告被发送到 machineA 上的 testLink)所以这里是控制台输出:
** Invoke test (first_time)
** Execute test
E:/Ruby/bin/ruby.exe test/modifierLocalisation.rb
Loaded suite test/modifierLocalisation
Started
F
Finished in 2.140625 seconds.
1) Failure:
test_me(ModifierLocalisation) [test/modifierLocalisation.rb:14]:
<false> is not true.
1 tests, 1 assertions, 1 failures, 0 errors
rake aborted!
我想当我在 machineA 上执行 jenkins 测试时,internet explorer 无法启动,这就是测试失败的原因。
知道我能做什么吗?
最佳答案
您可以从机器 A 远程运行您的 selenium 测试。
在你的代码更改中
ie = Watir::IE.new
到
capabilities = WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
ie = Watir::Browser.new(:remote, :url => 'http://machineB:4444/wd/hub', :desired_capabilities => capabilities)
ie = Watir::Browser.new :ie
关于ruby - 如何在 jenkins slave 上用 watir 运行 ruby 测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15810845/