首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用x3270驱动程序和黄瓜的Te3270 ruby代码示例

使用x3270驱动程序和黄瓜的Te3270 ruby代码示例
EN

Stack Overflow用户
提问于 2016-01-13 03:07:22
回答 1查看 878关注 0票数 0

我正在尝试在Ruby下使用cucumber自动化一些测试任务,使用TE3270 gem和X3270免费驱动程序连接到大型机平台,但打开大型机屏幕的一部分不能更进一步。

代码运行在Windows7,Ruby2.1上。

这是我根据TE3270网站上的内容编写的代码:

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

发布于 2016-03-17 00:02:50

我现在没有使用cucumber,但我确实有一些读写的工作代码。

作为platform.executable_command,我使用s3270 displayless工具编写抓屏脚本。(现在在Mac上,但我以前也在Windows上用过它;你只需要downloadinstall from source。)

到目前为止,让我能使用它的关键是wait_for_string函数。我还建议使用text方法来转储屏幕输出。

代码语言:javascript
复制
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.Enter
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34751853

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档