Friday, March 19, 2010
Descriptive Programming
- Launch Browser.
- Check whether the correct browser opened.
- Ensure the userName, password edits and the Sign-In button exist.
- Set the userName and password and Click Sign-In.
- Make sure the browser navigated to the correct page.
'We will use SystemUtil.Run to launch our target browserSystemUtil.Run "iexplore.exe", "http://newtours.demoaut.com/" If Browser( "title:=Welcome: Mercury Tours" ).Exist( 15 ) Then Reporter.ReportEvent micPass, "Step 1- Launch", "Correct browser was launched." Else Reporter.ReportEvent micFail, "Step 1- Launch", "Browser failed to launch." ExitTest End If 'Notice the use of the wildcard character belowWith Browser("title:=Welcome:.*").Page("title:=Welcome.*") If .WebEdit("name:=userName").Exist(0) Then .WebEdit("name:=userName").Set "test" If .WebEdit("name:=password").Exist(0) Then .WebEdit("name:=password").Set "test" If .Image("name:=login").Exist(0) Then .Image("name:=login").Click Else Reporter.ReportEvent micFail, "Sign-In Button Error", "Button not found." End If Else Reporter.ReportEvent micFail, "Password Edit Error", "EditBox not found." End If Else Reporter.ReportEvent micFail, "UserName Edit Error", "EditBox not found." End If End With Browser( "title:=.*Mercury.*" ).Sync If Browser( "title:=Find a Flight.*" ).Exist( 1 ) Then Reporter.ReportEvent micPass, "Login", "Login successful" Else Reporter.ReportEvent micFail, "Login", "Login failed" End If
*Collected from: http://relevantcodes.com/descriptive-programming-dp-4-creating-a-test-script/
Comments:
<< Home
Use test data directly from external (excel) sheet
http://www.learnqtp.com/use-test-data-directly-from-external-sheet/
http://www.learnqtp.com/use-test-data-directly-from-external-sheet/
One more eg:
systemutil.Run("http://www.rediffmail.com")
set BRO =Description.Create()
BRO("title").Value = "Welcome to Rediff.com India"
BRO("name").value ="Welcome to Rediff.com India"
BRO("openedbytestingtool").value= true
Set PG =Description.Create()
PG("title").value="Welcome to Rediff.com India"
PG("url").value="http://www.rediff.com/index.html"
Set UN =Description.Create()
UN("name").value= "login"
UN("Class Name").value ="WebEdit"
UN("type").value= "text"
UN("html tag").value="INPUT"
Set PWD =Description.Create()
PWD("name").value ="passwd"
PWD("Class Name").value="WebEdit"
PWD("type").value="password"
PWD("html tag").value="INPUT"
Set Login =Description.Create()
Login("name").value ="Go"
Login("Class Name").value="WebButton"
Login("type").value="submit"
Login("html tag").value="INPUT"
Login("value").value="GO"
Login("class").value="rmailgobtn"
temp= Browser("Welcome to Rediff.com").Page("Welcome to
Rediff.com").WebElement("ShockwaveFlash1").Exist
If temp= true Then
'Browser("Welcome to Rediff.com").Page("Welcome to
Rediff.com").WebElement("ShockwaveFlash1").
End If
Browser(BRO).Page(PG).WebEdit(UN).Set "shyam_sad"
Browser(BRO).Page(PG).WebEdit(PWD).Set "7shyam"
Browser(BRO).Page(PG).WebButton(Login).Click
systemutil.Run("http://www.rediffmail.com")
set BRO =Description.Create()
BRO("title").Value = "Welcome to Rediff.com India"
BRO("name").value ="Welcome to Rediff.com India"
BRO("openedbytestingtool").value= true
Set PG =Description.Create()
PG("title").value="Welcome to Rediff.com India"
PG("url").value="http://www.rediff.com/index.html"
Set UN =Description.Create()
UN("name").value= "login"
UN("Class Name").value ="WebEdit"
UN("type").value= "text"
UN("html tag").value="INPUT"
Set PWD =Description.Create()
PWD("name").value ="passwd"
PWD("Class Name").value="WebEdit"
PWD("type").value="password"
PWD("html tag").value="INPUT"
Set Login =Description.Create()
Login("name").value ="Go"
Login("Class Name").value="WebButton"
Login("type").value="submit"
Login("html tag").value="INPUT"
Login("value").value="GO"
Login("class").value="rmailgobtn"
temp= Browser("Welcome to Rediff.com").Page("Welcome to
Rediff.com").WebElement("ShockwaveFlash1").Exist
If temp= true Then
'Browser("Welcome to Rediff.com").Page("Welcome to
Rediff.com").WebElement("ShockwaveFlash1").
End If
Browser(BRO).Page(PG).WebEdit(UN).Set "shyam_sad"
Browser(BRO).Page(PG).WebEdit(PWD).Set "7shyam"
Browser(BRO).Page(PG).WebButton(Login).Click
Subscribe to Post Comments [Atom]
<< Home
Subscribe to Posts [Atom]
Post a Comment