【发布时间】:2013-09-26 02:40:00
【问题描述】:
您好,我目前是使用 Python 成为自动化 QA(Splinter)测试员的新手,我想做的是测试支付页面,看看是否有提示,如果必填字段为空,然后登录记事本。
我的问题是,当我使用alert.accept() 两次时,它不会在第二次运行。
例如:
第一个提示应该是“事务类型输入被困”,然后我使用alert.accept() 关闭提示。但是第二次它不起作用,提示只是停留在原处,并且在我使用alert.accept() 时不会自动单击确定按钮。为什么是这样?当我同时使用两个警报时,我是否遗漏了一条规则?
def checkTrappings():
logUtb(f, 'Checking if Transaction type is trapped, making payment with Transaction type as empty')
browser.find_by_id('submitBtn').first.click()
alert = browser.get_alert()
x = str(alert.text)
if x == 'Transaction Type is required.':
logUtb(f, 'Transaction Type input is trapped')
alert.accept()
logUtb(f, "")
logUtb(f, 'Checking if email is a valid email')
browser.select('tranType','A')
browser.find_by_id('submitBtn').first.click()
alert = browser.get_alert()
x = str(alert.text)
if x == 'Please enter a valid email address.':
logUtb(f, 'Proper email format is trapped')
alert.accept()
logUtb(f, "")
browser.find_by_id('submitBtn').first.click()
alert = browser.get_alert()
x = str(alert.text)
logUtb 是我的功能,我将报告记录到记事本
def logUtb(fl, strx):
now = datetime.datetime.now()
fl.write(now.strftime('%Y-%m-%d %H:%M') + " - " + strx + "\n");
return;
我正在使用的库是 splinter
【问题讨论】:
-
你用的是什么库?
-
我使用的库是分裂的
标签: python automated-tests splinter