从Robot Framework测试用例向Pywinauto启动程序

时间:2018-12-14 11:42:16

标签: robotframework pywinauto

我正在努力寻找一种方法来在RobotFramework中创建测试用例,并使pybot运行我创建的pywinauto脚本来测试程序是否将启动。目前,我可以执行此pywinauto脚本,因为我已在步骤中对exe app = Application().start(cmd_line=u'C:\\Program Files (x86)\\Expert Retail Systems\\BRMRunTime.exe')进行了硬编码。

我之所以这样问是因为,在此脚本之后,它还会在edit.type_keys(u'C:\RetailManager\RetailManager.bln')中打开文件,而我希望在RobotFramework中保存该文件,以便它可以报告文件是否能够启动。

我想做的是让RobotFramework接受关键字的值并将其插入到我的pywinauto脚本中。不确定是否应该修改Pywinauto脚本以接受RobotFramework的值,还是可以通过RobotFramework将其发送到Pywinauto。

这是完整的脚本。

from pywinauto.application import Application
#  Fire up the runtime program
app = Application().start(cmd_line=u'C:\\Program Files (x86)\\Expert Retail Systems\\BRMRunTime.exe')
window = app.Dialog  # Test to see if the dialog appears where the variable was declared
window.wait('ready')  # Wait for the window to be ready
combobox = window.ComboBox  # Find the combo box
combobox.click(u'Local Disk (C:)')  # Click the C:\ drive first
combobox.click(u'RetailManager')  # Then RetailManager
edit = window.Edit  # Use the edit module on the variable
edit.set_focus()  # Set the focus
edit.type_keys(u'C:\RetailManager\RetailManager.bln')
button = window[u'&Open']  # Find the button called Open
button.click()  # Click it when you find it
mainform = app[u'ThunderRT6FormDC']  # Declare a var for the form
mainform.wait('ready')  # Wait for the form to be ready
mainformdc = mainform[u'Menu System']  # Finds the menu system in the form
mainformdc.set_focus()  # Set the focus
mainformdc.print_control_identifiers()  # Check what elements were found useful for extending tests
app.kill()  # tells it to close the program being tested

0 个答案:

没有答案