下面是基于Expedia 航空订票业务系统的一个自动化测试案例,其中有几个关键的要点:
1、正则表达式,TestMore 采用类似于我们熟悉的Javascript正则表达式表示方式,用两个正斜杠符号"/"括起来表示;
2、同步等待时间,可以使用Window.Sync()方法等待默认时间,直到超时;或者使用Page.Wait(time)方法,它允许设置等待时间,页面加载完毕后自动化返回;
1、正则表达式,TestMore 采用类似于我们熟悉的Javascript正则表达式表示方式,用两个正斜杠符号"/"括起来表示;
2、同步等待时间,可以使用Window.Sync()方法等待默认时间,直到超时;或者使用Page.Wait(time)方法,它允许设置等待时间,页面加载完毕后自动化返回;
################################################################################
# Case Name: Test Case Template
# Description: Test case template for python
# Update History:
# - 2007-11-02 Andy.Tao Create test case template(Python version)
# -
################################################################################
import sys
import clr
import System
clr.AddReferenceByName("IEProvider")
from ZuHong.Automation.IEProvider import *
from System import *
ie = IEProcess()
ie.Wait(3000)
ie.MainWindow.Activate()
ie.MainWindow.Open("http://www.expedia.com/pub/agent.dll?qscr=fltw&fram=ForceHtx")
#Setup query parameters
ie.MainWindow.Sync()
page = ie.MainWindow.Page
#city1: Leaving from city
page.Select("ID=city1").Text = "SEA"
#citd1: Going to city
page.Select("ID=citd1").Text = "LAX"
#date1: Departuare date
page.Select("ID=date1").Text = DateTime.Now.AddMonths(3).ToString("MM/dd/yyyy")
#date2: Arrival date
page.Select("ID=date2").Text = DateTime.Now.AddMonths(3).AddDays(5).ToString("MM/dd/yyyy")
#A5001_14412: Search button
page.Select("ID=A5001_14412").Click()
#Select flights
page.Wait(8000)
#A5086_12100: Select this flight
page.SelectArray("id=A5086_12100")[0].Click()
page.Wait(3000)
page.SelectArray("id=A5086_12100")[0].Click()
#View flight detail
page.Wait(8000)
#chkb1: I have read and accept the rules and restrictions
page.Select("id=chkb1").Click()
#A5012_12828: Continue this booking
page.Select("id=A5012_12828").Click()
#Customize your trip
page.Wait(8000)
#A2148_7: Continue this booking
page.Select("id=A2148_7").Click()
#You need have account in Expedia.com from here
#Trip preference
page.Wait(13000)
#ninm: Itinerary Name
page.Select("name=ninm").Text = "TestMore Testing Trip_" + DateTime.Now.AddMonths(3).ToString("yyyyMMddHHmmss")
#trpr26_FWT_0_wtid: Traveler(Adults)
page.Select("id=trpr26_FWT_0_wtid").SelectedIndex = 1;
page.Wait(1000)
#A2118_1: Proceed to booking
page.Select("id=A2118_1").Click()
# Case Name: Test Case Template
# Description: Test case template for python
# Update History:
# - 2007-11-02 Andy.Tao Create test case template(Python version)
# -
################################################################################
import sys
import clr
import System
clr.AddReferenceByName("IEProvider")
from ZuHong.Automation.IEProvider import *
from System import *
ie = IEProcess()
ie.Wait(3000)
ie.MainWindow.Activate()
ie.MainWindow.Open("http://www.expedia.com/pub/agent.dll?qscr=fltw&fram=ForceHtx")
#Setup query parameters
ie.MainWindow.Sync()
page = ie.MainWindow.Page
#city1: Leaving from city
page.Select("ID=city1").Text = "SEA"
#citd1: Going to city
page.Select("ID=citd1").Text = "LAX"
#date1: Departuare date
page.Select("ID=date1").Text = DateTime.Now.AddMonths(3).ToString("MM/dd/yyyy")
#date2: Arrival date
page.Select("ID=date2").Text = DateTime.Now.AddMonths(3).AddDays(5).ToString("MM/dd/yyyy")
#A5001_14412: Search button
page.Select("ID=A5001_14412").Click()
#Select flights
page.Wait(8000)
#A5086_12100: Select this flight
page.SelectArray("id=A5086_12100")[0].Click()
page.Wait(3000)
page.SelectArray("id=A5086_12100")[0].Click()
#View flight detail
page.Wait(8000)
#chkb1: I have read and accept the rules and restrictions
page.Select("id=chkb1").Click()
#A5012_12828: Continue this booking
page.Select("id=A5012_12828").Click()
#Customize your trip
page.Wait(8000)
#A2148_7: Continue this booking
page.Select("id=A2148_7").Click()
#You need have account in Expedia.com from here
#Trip preference
page.Wait(13000)
#ninm: Itinerary Name
page.Select("name=ninm").Text = "TestMore Testing Trip_" + DateTime.Now.AddMonths(3).ToString("yyyyMMddHHmmss")
#trpr26_FWT_0_wtid: Traveler(Adults)
page.Select("id=trpr26_FWT_0_wtid").SelectedIndex = 1;
page.Wait(1000)
#A2118_1: Proceed to booking
page.Select("id=A2118_1").Click()