【问题标题】:Te3270 ruby code examples with x3270 driver and cucumber带有 x3270 驱动程序和黄瓜的 Te3270 ruby​​ 代码示例
【发布时间】:2016-04-17 13:14:18
【问题描述】:

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

代码在 Windows 7、Ruby 2.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

有什么想法吗?

问候, 强尼

【问题讨论】:

    标签: ruby automation cucumber


    【解决方案1】:

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

    我正在使用s3270 无显示工具编写屏幕抓取脚本作为platform.executable_command。 (现在在 Mac 上,但我过去也在 Windows 上使用过;你只需要 downloadinstall 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.Enter
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-23
      • 2013-10-22
      • 1970-01-01
      相关资源
      最近更新 更多