我正在尝试在Ruby下使用cucumber自动化一些测试任务,使用TE3270 gem和X3270免费驱动程序连接到大型机平台,但打开大型机屏幕的一部分不能更进一步。
代码运行在Windows7,Ruby2.1上。
这是我根据TE3270网站上的内容编写的代码:
require 'TE3270'
World(TE3270::ScreenFactory)
Before do
@emulator = TE3270.emulator_for :x3270 do |platform|
platform.executable_command = '"C:\Program Files (x86)\wc3270\wc3270.exe"'
platform.host = 'mainframe.hostname'
platform.max_wait_time = 5 # defaults to 10
platform.trace = true # turns on trace output from the emulator
end
end
Given /^my connection$/ do
my_screen = MainframeScreen.new(@emulator)
my_screen.userid = 'my_mainframe_user'
my_screen.password = 'my_mainframe_password'
end
class MainframeScreen
include TE3270
text_field(:userid, 19, 36, 8)
text_field(:password, 20, 36, 8)
def login(username, password)
self.userid = username
self.password = password
end
end有什么想法吗?
问候你,Jonny
发布于 2016-03-17 00:02:50
我现在没有使用cucumber,但我确实有一些读写的工作代码。
作为platform.executable_command,我使用s3270 displayless工具编写抓屏脚本。(现在在Mac上,但我以前也在Windows上用过它;你只需要download和install from source。)
到目前为止,让我能使用它的关键是wait_for_string函数。我还建议使用text方法来转储屏幕输出。
require 'te3270'
class MainframeScreen
include TE3270
text_field(:welcome, 3, 34, 14, false)
text_field(:application, 22, 21, 8)
end
emulator = TE3270.emulator_for :x3270 do |platform|
platform.executable_command = 's3270'
platform.host = '192.168.1.1'
end
screen = MainframeScreen.new(emulator)
screen.wait_for_string "Welcome to IBM", 3, 34
puts screen.welcome
screen.populate_screen_with :application => 'TSO'
screen.send_keys TE3270.Enterhttps://stackoverflow.com/questions/34751853
复制相似问题