QTP学习

'★★
'SystemUtil.Run "iexplore.exe","www.baidu.com"            '打开浏览器,并打开www.baidu.com
    '往百度输入框里填入 自动化测试技术领航
'    index = Browser("百度一下,你就知道")._                
'    Page("百度一下,你就知道").WebEdit("wd").GetROProperty("source_index")
'    Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("source_index:=" & index).set "自动化测试技术领航"


'★★获取百度webedit中的值并以msgbox展现
'getCount = Browser("百度一下,你就知道").Page("百度一下,你就知道")._            
'WebEdit("wd").Object.value:Msgbox getCount


'★★
'1.用with...end with来提炼公共的部分
'2.在百度搜索框中输入abc(封装接口进行赋值)
'3.在百度搜索框中输入abc(调用自身接口方式)
'With Browser("百度一下,你就知道").Page("百度一下,你就知道")                
    '.WebEdit("wd").Set "abc"                                            
    '.WebEdit("wd").Object.value="abc"                                
'End With



'★★以上例子的完全
'Browser("百度一下,你就知道").Page("百度一下,你就知道")._
'WebEdit("wd").Set "abc"                                                    
'Browser("百度一下,你就知道").Page("百度一下,你就知道")._
'WebEdit("wd").Object.value="abc"




'★★返回webedit对象中记录的innertext属性值
'ReturnValue = Browser("百度一下,你就知道").Page("百度一下,你就知道")._            
'WebEdit("wd").GetTOProperty("innertext")
'MsgBox ReturnValue             
'



'★★获取对象库中对象(bdlogo)的所有属性值
'Set TestObject  = Browser("百度一下,你就知道").Page("百度一下,你就知道").Image("bdlogo")        
'Set Properties = TestObject.GetTOProperties()
'PropertiesCount = Properties.Count
'Print "对象总计存在" & PropertiesCount & "个封装属性"
'For i = 0 To PropertiesCount -1
'    PropName = Properties(i).Name
'    PropValue = Properties(i).Value
'    Print PropName & "=" & PropValue
'Next
'Set Properties = Nothing
'Set TestObject = Nothing



'★★更改对象库中某个对象的值(运行时改变,运行结束还原)
'Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下")_        
'.SetTOProperty "name","百度一百万下"
'msgbox "观察name值"





'★★获取百度输入框中输入字符串的内容
'valuegetro = Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").GetROProperty("value")
'msgbox valuegetro



'★★获取micClass的值
'msgbox Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("wd").GetROProperty("micClass")


'★★找一辈子对象
'For i = 11 To 100
'    For j = 1 To 365
'    print "找对象"
'     Next 
'Next
'



'★★修改百度信息--暂时修改,刷新后恢复
'With Browser("百度一下,你就知道").Page("百度一下,你就知道")
'    .Object.title="移动卫士"
'    .Image("bdlogo").Object.src="http://www.ydcws.com/login?next=%2F"
'    .Link("关于百度").Object.innerText="关于移动卫士"
'    .Link("贴 吧").Object.innerText="移动卫士博客"
'    .Link("把百度设为主页").Object.innerText="把移动卫士设为主页"
'    .WebButton("百度一下").Object.value="移动卫士搜索"
'    .Link("加入百度推广").Object.innerText="加入移动卫士推广"
'    .Link("About Baidu").Object.innerText="About ydcws"
'    .WebElement("©2013 Baidu 使用百度前必读 京ICP证03017").Object.innerText="@2013 移动卫士"
'    .WebEdit("wd").Object.disabled="true"
'End With





'★★描述性编程:查看baidu首页有没有以下各个link,查找到显示true,否则false。注:网页为web element所以输出false
'Set baidu=Browser("micClass:=Browser").Page("micClass:=Page")
'With baidu
'print .link("name:=新 闻").Exist
'print .link("name:=网 页").Exist
'print .link("name:=贴 吧").Exist
'print .link("name:=知 道").Exist
'print .link("name:=音 乐").Exist
'print .link("name:=视 频").Exist
'print .link("name:=地 图").Exist
'End With
'Set baidu=Nothing
'


'
'★★打开baidu高级搜索,检测edit,每检测到一个edit就向其中输入值("测试")
'最后set 参数=Nothing----释放设置的对象
'SystemUtil.Run "iexplore.exe","www.baidu.com/gaoji/advanced.html"
'Set all_webedit = Description.Create
'all_webedit("micClass").Value="WebEdit"
'Set all_webedits=Browser("micClass:=Browser").Page("micClass:=Page").ChildObjects(all_webedit)
'For i = 0 To all_webedits.count-1
'    Set Edit=all_webedits.item(i)
'    Edit.Set "测试"
'Next
'Set all_webedit=Nothing
'Set all_webedits=Nothing
'Set edit=Nothing

'★★两种描述性编程方法1.普通方法   2.使用Description.Create方法
'对象库代码:
'title = Browser("百度一下,你就知道").Page("百度一下,你就知道").Object.title
'msgbox Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下").GetROProperty("value")
'Browser("百度一下,你就知道").Page("百度一下,你就知道").Link("关于百度").Click

'方法1
'title = Browser("title:=百度一下,你就知道").Page("title:=百度一下,你就知道").Object.title
'msgbox Browser("title:=百度一下,你就知道").Page("title:=百度一下,你就知道").WebButton("name:=百度一下").GetROProperty("value")
'Browser("title:=百度一下,你就知道").Page("title:=百度一下,你就知道").Link("name:=关于百度").Click


'方法2
'Set BrowserDesc=Description.Create
'Set ButtonDesc=Description.Create
'Set LinkDesc=Description.Create
'BrowserDesc("title").value="百度一下,你就知道"
'ButtonDesc("name").value="百度一下"
'LinkDesc("text").value="关于百度"
'msgbox Browser(BrowserDesc).Page(BrowserDesc).WebButton(ButtonDesc).GetROProperty("value")
'Browser(BrowserDesc).Page(BrowserDesc).Link(LinkDesc).Click




'SystemUtil.Run "iexplore.exe","www.baidu.com"
'在百度搜索框输入Action1中的数据并点击“百度一下”后返回--循环
'testData= DataTable.Value("数据","Action1")
'With Browser("百度一下,你就知道").Page("百度一下,你就知道")
'    .WebEdit("wd").Set DataTable.Value("数据","Action1")
'    .WebButton("百度一下").Click    
'End With
'Browser("micClass:=Browser").Back
'



'验证百度搜索框与搜索结果框是否相同,取运行时对象(全局表才可以共享)
'SystemUtil.Run "iexplore.exe","www.baidu.com" @@ hightlight id_;_13_;_script infofile_;_ZIP::ssf13.xml_;_
'Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("搜索框").Set "自动化测试技术"
'Run_time= Browser("百度一下,你就知道").Page("百度一下,你就知道").WebEdit("搜索框").GetROProperty("value")
'DataTable.Value("Runtime_Data","Global")=Run_time
'Browser("百度一下,你就知道").Page("百度一下,你就知道").WebButton("百度一下").Click
'Run_time=DataTable.Value("Runtime_Data","Global")
'CheckValue = Browser("百度一下,你就知道").Page("自动化测试技术领航_百度搜索").WebEdit("搜索关键字页面").GetROProperty("value")
'If CheckValue = Run_time Then
'    msgbox true
'    Else
'    msgbox false
'End If
'


'在全局变量里添加字段
'DataTable.GlobalSheet.AddParameter "abc","value"
'msgbox " "


'向表Action1中数据列第8行写入值row2
'DataTable.GetSheet("Action1").SetCurrentRow (8)
'DataTable.Value("数据","Action1")="row2"
'msgbox "a"
'

posted @ 2013-11-26 11:38  Free-program  阅读(307)  评论(0)    收藏  举报