QTP測試多個瀏覽器視窗的解決方案
relevantcodes.com的《QTP: Working with Multiple Browser Applications》這篇文章介紹瞭如何測試多個瀏覽器視窗的情況:
http://relevantcodes.com/qtp-working-with-multiple-browser-applications-revised/
解決辦法的關鍵是根據什麼來區別出不同的瀏覽器視窗並儲存其控制程式碼。文章介紹了2類方法:
1、使用標題來識別出瀏覽器視窗並儲存瀏覽器視窗控制程式碼
2、最近開啟的瀏覽器視窗擁有的CreationTime屬性最大,可以據此來區別不同的瀏覽器視窗,並分別儲存它們的控制程式碼
把這些識別並儲存瀏覽器視窗控制程式碼的程式碼封裝在clsBrowser.cls檔案中的colBrowser類。主要函式有:
AddUsingTitle:Uses the "AddBrowser" method to add browsers to the collection using their Title Property
AddUsingCreationTime :Uses the "AddBrowser" method to add browsers to the collection using their CreationTime Property
AddLastOpen:Uses the "AddBrowser" method to add the last (most recent) open browser
Note: The last open browser always has the greatest CreationTime
使用例子如下所示(BrowserObject物件就是colBrowser類產生的物件):
'==================================
' Add Using Title
'==================================
SystemUtil.Run "iexplore.exe", "http://newtours.demoaut.com", "", "", 3 : Wait(4)
'Add the browser above using its title, and with the name DemoAUT
BrowserObject.AddUsingTitle "DemoAUT", ".*Mercury Tours.*"
SystemUtil.Run "iexplore.exe", "http://blog.csdn.net/testing_is_believing", "", "", 3 : Wait(4)
'Add the browser above using its title, and with the name RelevantCodes
BrowserObject.AddUsingTitle "MyBlog", "實用性測試(Pragmatistic Testing) - CSDN部落格"
With BrowserObject.Name("DemoAUT")
.WebEdit("name:=userName").Set "test"
.WebEdit("name:=password").Set "test"
.Image("name:=login").Click
.Sync
If .WebList("name:=fromPort").Exist(10) Then
.WebList("name:=fromPort").Select "Frankfurt"
.WebList("name:=fromMonth").Select "December"
.WebList("name:=toPort").Select "Paris"
.WebList("name:=toMonth").Select "December"
.WebRadioGroup("name:=servClass").Select "#1"
.WebList("name:=airline").Select "Unified Airlines"
.Image("name:=findFlights").Click
End If
End with
With BrowserObject.Name("MyBlog")
.Link("text:=《QTP自動化測試實踐》", "index:=").Click
End with
With BrowserObject
.Name("DemoAUT").Close
.Name("MyBlog").Close
End with
'==================================
' Add Last Open
'==================================
SystemUtil.Run "iexplore.exe", "http://newtours.demoaut.com", "", "", 3 : Wait(4)
'Add the above browser using AddLastOpen
BrowserObject.AddLastOpen "DemoAUT"
SystemUtil.Run "iexplore.exe", "http://blog.csdn.net/testing_is_believing", "", "", 3 : Wait(4)
'Add the above browser using AddLastOpen
BrowserObject.AddLastOpen "MyBlog"
With BrowserObject.Name("DemoAUT")
.WebEdit("name:=userName").Set "test"
.WebEdit("name:=password").Set "test"
.Image("name:=login").Click
.Sync
If .WebList("name:=fromPort").Exist(10) Then
.WebList("name:=fromPort").Select "Frankfurt"
.WebList("name:=fromMonth").Select "December"
.WebList("name:=toPort").Select "Paris"
.WebList("name:=toMonth").Select "December"
.WebRadioGroup("name:=servClass").Select "#1"
.WebList("name:=airline").Select "Unified Airlines"
.Image("name:=findFlights").Click
End If
End with
With BrowserObject.Name("MyBlog")
.Link("text:=《QTP自動化測試實踐》", "index:=").Click
End with
With BrowserObject
.Name("DemoAUT").Close
.Name("MyBlog").Close
End with
'==================================
' Add Using CreationTime
'==================================
SystemUtil.Run "iexplore.exe", "http://newtours.demoaut.com", "", "", 3 : Wait(4)
'Add the above browser using CreationTime 0, assuming no other browsers are open
BrowserObject.AddUsingCreationTime "DemoAUT", 0
SystemUtil.Run "iexplore.exe", "http://blog.csdn.net/testing_is_believing", "", "", 3 : Wait(4)
'Add the above browser using CreationTime 1, assuming no other browsers are open prior to above
BrowserObject.AddUsingCreationTime "MyBlog", 1
With BrowserObject.Name("DemoAUT")
.WebEdit("name:=userName").Set "test"
.WebEdit("name:=password").Set "test"
.Image("name:=login").Click
.Sync
If .WebList("name:=fromPort").Exist(10) Then
.WebList("name:=fromPort").Select "Frankfurt"
.WebList("name:=fromMonth").Select "December"
.WebList("name:=toPort").Select "Paris"
.WebList("name:=toMonth").Select "December"
.WebRadioGroup("name:=servClass").Select "#1"
.WebList("name:=airline").Select "Unified Airlines"
.Image("name:=findFlights").Click
End If
End with
'Added Index - November 06, 2009 - Credits: Clive Farrington
With BrowserObject.Name("MyBlog")
.Link("text:=《QTP自動化測試實踐》", "index:=").Click
End with
With BrowserObject
.Name("DemoAUT").Close
.Name("MyBlog").Close
End with
相關文章
- QTP測試多個Windows應用程式的解決方案QTWindows
- 解決JS彈出新視窗被瀏覽器阻止的解決方案JS瀏覽器
- 使用window.open開啟新視窗被瀏覽器攔截的解決方案瀏覽器
- 解決新版谷歌瀏覽器無法關閉視窗的問題谷歌瀏覽器
- Mac上如何測試IE瀏覽器相容性-虛擬機器解決方案Mac瀏覽器虛擬機
- 瀏覽器的視窗位置和大小瀏覽器
- js獲取瀏覽器視窗的大小JS瀏覽器
- BrowserSync——多裝置瀏覽器同步測試工具瀏覽器
- 瀏覽器相容性問題解決方案之CSS,已在IE、FF、Chrome測試瀏覽器CSSChrome
- chrome瀏覽器最小字號解決方案Chrome瀏覽器
- jQuery獲取瀏覽器視窗和文件視窗的高度程式碼jQuery瀏覽器
- 突破瀏覽器域名併發限制的解決方案瀏覽器
- js獲取瀏覽器視窗屬性JS瀏覽器
- JavaScript中解決多瀏覽器相容性23個問題的快速解決方法JavaScript瀏覽器
- 瀏覽器支援ES6的最優解決方案瀏覽器
- Edge瀏覽器被搜狗瀏覽器篡改的解決方法瀏覽器
- 跨瀏覽器測試需要面臨哪些挑戰?跨瀏覽器測試工具分享瀏覽器
- 嘗試寫個UC瀏覽器(堆疊檢視A)瀏覽器
- 關閉瀏覽器視窗彈出警告視窗程式碼例項瀏覽器
- 瀏覽器利用框架BeEF測試瀏覽器框架
- angular瀏覽器相容性問題解決方案Angular瀏覽器
- 瀏覽器同源策略及 Ajax 跨域解決方案瀏覽器跨域
- 實現瀏覽器跨域解決方案介紹瀏覽器跨域
- 拖拽防止火狐瀏覽器開啟新視窗瀏覽器
- jqueryeasyUI dialog 彈出視窗超出瀏覽器jQueryUI瀏覽器
- QTP測試Windows計算器QTWindows
- 為什麼跨瀏覽器測試很重要?7款跨瀏覽器測試工具請查收!瀏覽器
- uc瀏覽器字型放大解決方案瀏覽器
- 主流瀏覽器相容性問題與解決方案瀏覽器
- 瀏覽器相容性問題解決方案 · 總結瀏覽器
- 介面測試的解決方案
- javascript獲取瀏覽器視窗尺寸程式碼片段JavaScript瀏覽器
- Mocha瀏覽器測試入門教程瀏覽器
- HTML5支援所有瀏覽器的SHIV解決方案HTML瀏覽器
- SSL-Explorer基於web瀏覽器的VPN解決方案Web瀏覽器
- Fluid Browser for Mac(多工懸浮透明視窗瀏覽器)1.6啟用版UIMac瀏覽器
- 重學瀏覽器(1)-多程式多執行緒的瀏覽器瀏覽器執行緒
- CSS瀏覽器相容性的4個解決方案:瀏覽器CSS樣式初始化、瀏覽器私有屬性,CSS hack語法和自動化外掛CSS瀏覽器