QTP 学习笔记

QTP学习笔记

1.    What is the command in QTP to invoke IEBrow?

Thereare three ways to invoke IE browser and launch a website from QTP.

1.First we use the method called as "InvokeApplication"

 

Syntax:InvokeApplication "Path"

 

Example:invokeapplication "C:Program FilesInternet Exploreriexplore.exe"

(Thiswill launch IE browser)

 

Example:invokeapplication "C:Program FilesInternetExplorerIExplore.exe","www.google.com"

(Thiswill launch IE browser and also a particular web site like google.com)

 

 

Example:invokeapplication "C:Program FilesMercury InteractiveQuickTestProfessionalbinQTPro.exe"

(Thiswill invoke QTP)

 

 

2. Wewill use the "SystemUtil" object associated with a "Run"method

 

Syntax:SystemUtil.Run "Application/URL"

 

Example:SystemUtil.Run "iexplore.exe"

 

Example:Systemutil.Run "C:Program FilesInternetExplorerIExplore.exe","www.google.com"

 

Example:SystemUtil.Run http://www.google.com

 

(Herewhen you run this line of code systemutil.run executes a method called run bywhich the IE browser

isopened and also the url mentioned is launched. This is useful when you want QTPto directly launch the

websiteyou want in a single step)

 

3.When you want to invoke IE and then launch a url through script you can use theobject function linrary.

 

Syntax:Set IE1=CreateObject("InternetExplorer.Application")

IE1.visible=True

IE1.Navigate("sitename") /* with this you can navigate to the URL*/

 

Example:Set IE = CreateObject("InternetExplorer.Application")

IE.Visible= True

IE.Navigatehttp://www.google.com

 

2.    Get current Action name

Environment.Value("ActionName")

 

Example:

Reporter.ReportEventmicFail,Environment.Value("ActionName") ,"实际输出:"&actualScale&",预计输出:"&expectedScale

 

3.    提取数字的正则表达式

  SetregEx = CreateObject("VBScript.RegExp")

    regEx.Pattern = "[^0-9]"

    regEx.Global=True

 

  MsgBox regEx.Replace(“abc123456-78-9好吧”)

 

4.    移动光标的语句

DimdeviceReplayObject

SetdeviceReplayObject = CreateObject("Mercury.DeviceReplay")

CalldeviceReplayObject.MouseMove(0, 0)

 

5.    让组件可见

比如,一个组件需要滑动滚动条到页面的低端才能让其可见,可使用:

 

Browser(GISBrowser).Page(GISPage).WebElement(pMenu).MakeObjVisible

 

*MakeObjVisible方法能将不可见的组件滑动到可视范围、

*Scrolls an ActiveX object into view if it is not visible in thewindow.

6.    判断控件是否可见

等待判断控件是否可见,然后好进行下一步操作

If Browser(GISBrowser).Page(GISPage).WebElement(satelliteImage).WaitProperty("visible", "True", 20000)Then

    Browser(GISBrowser).Page(GISPage).WebElement(pMenu).Click

    wait(3)

    Browser(GISBrowser).Page(GISPage).Link(cMenu).Click

   End If 

 

7.    等待浏览器变成完成状态

等待浏览器变成完成状态,页面有AJAX请求也是好使的

   '等待浏览器的状态变成”完成“状态

   Do While Browser(GISBrowser).Page(GISPage).Object.readyState<>"complete"

wait(1)

       Loop

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值