⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 script.mts

📁 QTP实例源码(完整)
💻 MTS
📖 第 1 页 / 共 5 页
字号:
Option Explicit
'=================================================================
Dim  fso,file,filename,objTestLib,objmsgbox,oDesc,Edits,WebCheckBoxs
Dim  strMessage,strTemp,strValue,strEditValue,strEditName,NumberOfEdits
Dim  strInnertext,intLoop,intFlag,Err_Flag,arrLink
Dim  arrExpectValue,arrOriginalValue(5),arrTempValue(5),strOriginalValue
'=================================================================
'fetch filename form the global sheet
'filename = "c:\log.txt"
filename = DataTable.RawValue("filename",dtGlobalSheet)
'create a new file system object to output information
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile(filename,8,True)
Set objTestLib = createobject("TestLib.CLib")
'create a new sqamsgbox object
Set objmsgbox = CreateObject("SQAMsgbox.CMsgbox")
'=================================================================
Err_Flag = True
'=================================================================

'On Error Resume Next

Call objTestLib.printfile(file,2,"2 -- Script: Administrator Tools")
objmsgbox.SQAMsgbox "Part 2 -- Script: Administrator Tools","AA Auto Test",3,0

Browser("Accela Automation:").Page("Accela Automation:").Image("tab_menu").Click @@ script infofile_;_ZIP::tab_menu_ssf1.inf_;_hightlight id_;_Browser("Accela Automation:").Page("Accela Automation:").Image("tab menu")_;_NFB_;_20693_;_

'###############################Section 1:  AGENCY PROFILE #####################
Call objTestLib.printfile(file,3,"Section 1: AGENCY PROFILE ")
objmsgbox.SQAMsgbox "Section 1: AGENCY PROFILE ","AA Auto Test",3,0
'===============1. Standard Choices
If Browser("Accela Automation:").Page("Accela Automation:").Link("Standard Choices").Exist Then
   Call objTestLib.printfile(file,3,"   1. Standard Choices")
   Browser("Accela Automation:").Page("Accela Automation:").Link("Standard Choices").Click
   Call SearchStandChoices()
   If Err_Flag=False Then
   	   call UpdateStandChoices()
       If Err_Flag=False Then
	   	  call RevertStandChoices()
	   End If
   End If
   If Err_Flag=False And Browser("Accela Automation:_4").Page("Accela Automation:_2").Image("Delete").Exist Then
   	  call AddSCValue()
	  If Err_Flag=False Then
   	  	  call DeleteSCValue()
	  End If
   End If
Else
   Call objTestLib.printfile(file,3,"   1. Standard Choices -- cannot find this link, SKIP")
End If

Function SearchStandChoices ()
	Err_Flag = True
	'a. Search an existing standard choices
	Call objTestLib.printfile(file,3,"      a. Search an existing standard choices")
	Browser("Accela Automation:_2").Page("Accela Automation:").Image("Search").Click @@ script infofile_;_ZIP::Search_ssf3.inf_;_hightlight id_;_Browser("Accela Automation: 2").Page("Accela Automation:").Image("Search")_;_NFB_;_20695_;_
	If Browser("Accela Automation:_3").Page("Accela Automation:").Image("Edit").Exist(10) Then
		Err_Flag = False
	    Call objTestLib.printfile(file,4)
	Else
	   	Call objTestLib.printfile(file,3,"       ---None, no record exists in system, please add first!")
	End If
End Function

Function UpdateStandChoices ()
	Err_Flag = True
	'b.update the first standard choice by different data
	Call objTestLib.printfile(file,3,"      b.update the first standard choice by different data")
	Browser("Accela Automation:_3").Page("Accela Automation:").Image("Edit").Click @@ script infofile_;_ZIP::Edit_ssf4.inf_;_hightlight id_;_Browser("Accela Automation: 3").Page("Accela Automation:").Image("Edit")_;_NFB_;_20696_;_
	arrOriginalValue(1) = Browser("Accela Automation:_4").Page("Accela Automation:").WebEdit("txtBIZDOMAIN_DESC").GetROProperty("value")
	arrOriginalValue(2) = Browser("Accela Automation:_4").Page("Accela Automation:").WebRadioGroup("txtREC_STATUS").GetROProperty("value")
	arrExpectValue = Array("","Agency Testing","I")
	Call UpdateSCValue(arrExpectValue)
	If Err_Flag=True Then
	    Call objTestLib.printfile(file,5,"Updated standard choice failed" & strMessage)
	Else
		Call VerifySCValue(arrExpectValue)
	End If
End Function

Function UpdateSCValue (arrUpdateValue)
	Err_Flag = True
	Browser("Accela Automation:_4").Page("Accela Automation:").WebEdit("txtBIZDOMAIN_DESC").Set arrUpdateValue(1) @@ script infofile_;_ZIP::txtBIZDOMAIN_DESC_ssf5.inf_;_hightlight id_;_Browser("Accela Automation: 4").Page("Accela Automation:").WebEdit("txtBIZDOMAIN DESC")_;_NFB_;_20697_;_
	Browser("Accela Automation:_4").Page("Accela Automation:").WebRadioGroup("txtREC_STATUS").Select arrUpdateValue(2) @@ script infofile_;_ZIP::txtREC_STATUS_ssf6.inf_;_hightlight id_;_Browser("Accela Automation: 4").Page("Accela Automation:").WebRadioGroup("txtREC STATUS")_;_NFB_;_20697_;_
	Browser("Accela Automation:_4").Page("Accela Automation:").Image("Update Value").Click @@ script infofile_;_ZIP::Update_Value_ssf7.inf_;_hightlight id_;_Browser("Accela Automation: 4").Page("Accela Automation:").Image("Update Value")_;_NFB_;_20697_;_
	If Browser("Accela Automation:_4").Page("Accela Automation:").WebRadioGroup("txtREC_STATUS").Exist(5) Then
		Err_Flag = False
	Elseif Browser("Accela Automation:_4").Dialog("Microsoft Internet").WinButton("OK").Exist Then
		strMessage = Browser("Accela Automation:_4").Dialog("Microsoft Internet").Static("Warnning").GetROProperty("text")
		Browser("Accela Automation:_4").Dialog("Microsoft Internet").WinButton("OK").Click
	Else
		strMessage = "there occurs an unexpected error!"
	End If
End Function

Function VerifySCValue (arrUpdateValue)
	Dim  arrTempValue(2),intLoop,intLength
	arrTempValue(1) = Browser("Accela Automation:_4").Page("Accela Automation:").WebEdit("txtBIZDOMAIN_DESC").GetROProperty("value")
	arrTempValue(2) = Browser("Accela Automation:_4").Page("Accela Automation:").WebRadioGroup("txtREC_STATUS").GetROProperty("value")
	If arrTempValue(1)=arrUpdateValue(1) And arrTempValue(2)=arrUpdateValue(2) Then
	    Call objTestLib.printfile(file,4)
	Else
		Call objTestLib.printfile(file,5,"Updated standard choice failed")
	End If
End Function

Function RevertStandChoices ()
	'c.revert the first standard choice by original data
	Call objTestLib.printfile(file,3,"      c.revert the first standard choice by original data")
	Call UpdateSCValue(arrOriginalValue)
End Function

Function AddSCValue ()
	Err_Flag = True
	'd.add a new Standard Choices Value
	Call objTestLib.printfile(file,3,"      d.add a new Standard Choices Value")
	Browser("Accela Automation:_4").Page("Accela Automation:").Image("Add Value").Click @@ script infofile_;_ZIP::Add_Value_ssf11.inf_;_hightlight id_;_Browser("Accela Automation: 4").Page("Accela Automation:").Image("Add Value")_;_NFB_;_20699_;_
	wait(5)
	Browser("Accela Automation:_95").Page("Accela Automation:").WebEdit("txtBIZDOMAIN_VALUE").Set "Agency Testing" @@ script infofile_;_ZIP::txtBIZDOMAIN_VALUE_ssf485.inf_;_hightlight id_;_Browser("Accela Automation: 95").Page("Accela Automation:").WebEdit("txtBIZDOMAIN VALUE")_;_NFB_;_1781353_;_
	Browser("Accela Automation:_95").Page("Accela Automation:").Image("Submit").Click @@ script infofile_;_ZIP::Submit_ssf489.inf_;_hightlight id_;_Browser("Accela Automation: 95").Page("Accela Automation:").Image("Submit")_;_NFB_;_1781353_;_
	If Browser("Accela Automation:_4").Page("Accela Automation:_2").Image("Delete").Exist(5) Then
		If SearchEditValue("Agency Testing",4)=1 Then
			Err_Flag = False
        	Call objTestLib.printfile(file,4)
		Else
			Call objTestLib.printfile(file,5,"added new value failed!")
		End If
	Elseif Browser("Browser").Dialog("Microsoft Internet").WinButton("OK").Exist Then
		strMessage = Browser("Browser").Dialog("Microsoft Internet").Static("Warnning").GetROProperty("text")
		Browser("Browser").Dialog("Microsoft Internet").WinButton("OK").Click @@ script infofile_;_ZIP::Microsoft_Internet_Explorer_ssf375.inf_;_hightlight id_;_1_;_
		Call objTestLib.printfile(file,5,"updated the Contact failed, the error message is " & strMessage)
	Else
		Call objTestLib.printfile(file,5,"there occurs an unexpected error!")
		Browser("Accela Automation:").back
	End If
End Function

Function SearchEditValue (strValue,intPageNo)
	Dim  oDesc,Edits,WebCheckBoxs
	wait(5)
	Set oDesc = Description.Create() 
	oDesc("micclass").Value = "WebEdit"
	Set Edits = Browser("Accela Automation:_" & intPageNo).Page("Accela Automation:").ChildObjects(oDesc)
	NumberOfEdits = Edits.Count()
	SearchEditValue = 0
	For intLoop = 0 To NumberOfEdits-1 
		strEditValue = Edits(intLoop).GetROProperty("value")
		If strEditValue=strValue Then
	   	   strEditName = Edits(intLoop).GetROProperty("name")
		   SearchEditValue = 1
		   Exit For
		End If
	Next
End Function

Function DeleteSCValue ()
	Err_Flag = True
	'e.delete the new Standard Choices Value
	Call objTestLib.printfile(file,3,"      e.delete the new Standard Choices Value")
	Browser("Accela Automation:_4").Page("Accela Automation:_2").Image("Delete").Click @@ script infofile_;_ZIP::Delete_ssf14.inf_;_hightlight id_;_Browser("Accela Automation: 4").Page("Accela Automation: 2").Image("Delete")_;_NFB_;_40701_;_
	Browser("Accela Automation:_4").Dialog("Microsoft Internet").WinButton("OK").Click @@ script infofile_;_ZIP::Microsoft_Internet_Explorer_ssf15.inf_;_hightlight id_;_2_;_
	If Browser("Accela Automation:_4").Page("Accela Automation:").WebRadioGroup("txtREC_STATUS").Exist(5) Then
		Err_Flag = False
		If SearchEditValue("Agency Testing",4)=0 Then
            Call objTestLib.printfile(file,4)
		Else
			Call objTestLib.printfile(file,5,"the [Agency Testing] value still exists!")
		End If
	Elseif Browser("Accela Automation:_4").Dialog("Microsoft Internet").WinButton("OK").Exist Then
		strMessage = Browser("Accela Automation:_4").Dialog("Microsoft Internet").Static("Warnning").GetROProperty("text")
		Browser("Accela Automation:_4").Dialog("Microsoft Internet").WinButton("OK").Click
		Call objTestLib.printfile(file,5,"cannot delete the added value, the error message is " & strMessage)
	Else
		strMessage = "there occurs an unexpected error!"
		Call objTestLib.printfile(file,5,"cannot delete the added value, the error message is " & strMessage)
	End If
End Function

'Browser("Accela Automation:_4").Page("Accela Automation:_3").Image("tab_menu").Click @@ script infofile_;_ZIP::tab_menu_ssf16.inf_;_hightlight id_;_Browser("Accela Automation: 4").Page("Accela Automation: 3").Image("tab menu")_;_NFB_;_40702_;_
Browser("Accela Automation:").Page("Accela Automation:").Image("tab_menu").Click

'###############################Section 2:  USER PROFILE #####################
Call objTestLib.printfile(file,3,"Section 2: USER PROFILE ")
objmsgbox.SQAMsgbox "Section 2: USER PROFILE ","AA Auto Test",3,0
'=====1 . Organizations
If Browser("Accela Automation:").Page("Accela Automation:").Link("Organizations").Exist Then
   Call objTestLib.printfile(file,3,"   1. Organizations") @@ script infofile_;_ZIP::Accela_Automation__ssf17.inf_;_hightlight id_;_Browser("Accela Automation:").Page("Accela Automation:")_;_NFB_;_40703_;_
   Browser("Accela Automation:").Page("Accela Automation:").Link("Organizations").Click @@ script infofile_;_ZIP::Organizations_ssf18.inf_;_hightlight id_;_Browser("Accela Automation:").Page("Accela Automation:").Link("Organizations")_;_NFB_;_50705_;_
   Call UpdateOrg()
   If Err_Flag=False Then
   	  call RevertOrg()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -