rf的testcase文件:
*** Settings ***
Library ../Methodlibrary/keywords.py
*** Test Cases ***
弹框输入文本
${orderid} getinputstr please input orderId
log ${orderid}
keywords.py文件(python2版本):
# -*- coding: utf-8 -*-
from Tkinter import *
inputstr = ''
def getinputstr(title):
"""
设置弹出框的标题,得到输入框内容,不允许为空值。目前不允许输入中文,可以粘贴中文,rf中标题不能直接用中文。
"""
def putstr():
global inputstr
inputstr = str(var.get().strip().encode('utf-8'))
root.destroy()
if inputstr is not '':
pass
else:
inputstr = getinputstr(title)
def inputclear():
var.set('')
inputstr = ''
root = Tk(className=title) # 弹出框框名
# screenwidth, screenheight = root.maxsize()
width = 300
height = 80
# size = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2) # 居中显示
size = '%dx%d' % (width, height)
root.geometry(