自动化测试专家,专注于自动化测试领域的框架开发及国外最新自动化技术,担任过银行、电子商务等项目的自动化测试工作,精通自动化测试工具QTP、Watir等.并对QTP有过深入的研究,有过企业内训和工具培训经验,希望能与各位同行一起沟通,交流,探讨。 zzxxbb112@hotmail.com

【QTP系列讲座 28】==正则表达式的应用 ==

上一篇 / 下一篇  2011-10-31 16:59:23 / 个人分类:QTP系列讲座

 Rss订阅IQuickTest关于如何订阅?51Testing软件测试网_Q1c._ h2G4x!L

GoogleReader订阅地址: http://feeds.feedburner.com/iquicktest

T.Yz3L.P+z"q0

作者:zzxxbb112
时间:2010/2/23 版权所有,侵权必究。51Testing软件测试网z*]Oaa*c_| k

出处:http://blog.csdn.net/zzxxbb11251Testing软件测试网Q'@ _3Z!u0a+BH r,as


正则表达式相信很多朋友都不陌生,它是一个非常常用的技术,不管是在什么语言中,今天我们就来看一下QTP中正则表达式的应用。51Testing软件测试网#Z6gHV\C7SwF

  • 描述性编程的应用

I-P3Ij/~5Ve,k.Dz)d0
  1. systemutil.Run "iexplore.exe","www.baidu.com"   
  2. Browser("title:=.*").Page("name:=.*").WebEdit("name:=wd").Set "zzxxbb112"  
51Testing软件测试网 hB1^O7s'_2i

51Testing软件测试网+kZa t6Z t?faYs

当我们在使用描述性编程时,我们可以使用正则来代替长标题 51Testing软件测试网a `Z3H!b [h

  • VBS中REGEXP的应用

在VBS中有一个叫REGEXP的类,它提供了简单的正则支持

'td4y5h@ O7{0

51Testing软件测试网 G'\a_%l}J9s

  1. Function RegExpTest(patrn, strng)  
  2.    Dim regEx, Match, Matches   ' Create variable.  
  3.    Set regEx = New RegExp   ' Create a regular expression.  
  4.    regEx.Pattern = patrn   ' Set pattern.  
  5.    regEx.IgnoreCase = True   ' Set case insensitivity.  
  6.    regEx.Global = True   ' Set global applicability.  
  7.    Set Matches = regEx.Execute(strng)   ' Execute search.  
  8.    For Each Match in Matches   ' Iterate Matches collection.  
  9.       RetStr = RetStr & "Match found at position "  
  10.       RetStr = RetStr & Match.FirstIndex & ". Match Value is '"  
  11.       RetStr = RetStr & Match.Value & "'." & vbCRLF  
  12.    Next  
  13.    RegExpTest = RetStr  
  14. <span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style. initial; border-color: initial; border-top-style. none; border-

TAG: iquicktest QTP qtp

 

评分:0

我来说两句

我的栏目

日历

« 2024-04-11  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 32210
  • 日志数: 49
  • 建立时间: 2009-10-17
  • 更新时间: 2011-10-31

RSS订阅

Open Toolbar