加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

QTP的描述性编程与正则表达式

发布时间:2020-12-14 01:48:31 所属栏目:百科 来源:网络整理
导读:在使用QTP描述性编程的方式进行脚本编写时,通常需要应用到正则表达式,relevantcodes.com的这篇文章《Descriptive Programming (DP) Concepts – 2 {Regular Expressions}》详细描述了正则表达式(尤其是通配符)在DP中的使用: http://relevantcodes.com/d

在使用QTP描述性编程的方式进行脚本编写时,通常需要应用到正则表达式,relevantcodes.com的这篇文章《Descriptive Programming (DP) Concepts – 2 {Regular Expressions}》详细描述了正则表达式(尤其是通配符)在DP中的使用:

http://relevantcodes.com/descriptive-programming-dp-concepts-2-regular-expressions/

例如通配符的用法:

Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("file name:=banner2.gif").Highlight

Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("file name:=banner2.*").Highlight

Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("file name:=banner.*").Highlight

Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("file name:=ban.*gif").Highlight

Browser("title:=Welcome: Mercury Tours").Page("title:=Welcome: Mercury Tours").Image("file name:=ban.*f").Highlight

文中以Mercury Tours为例介绍了一些正则表达式的使用方法,例如:

' Using the first few characters of the title and the first few characters of the image

Browser("title:=Welc/w+/D+/w+").Page("title:=Welc/w+/D+/w+").Image("file name:=ban/w+/d+/./w+").Highlight

' Using the last few characters of the title with first and last characters of the image

Browser("title:=/w+/D+/w+ours").Page("title:=/w+/D+/w+ours").Image("file name:=b/w+2/.gif").Highlight

' Same as above for Browser and Page,but '...' for image

Browser("title:=/w+/D+/w+ours").Page("title:=/w+/D+/w+ours").Image("file name:=b/w+2/....").Highlight

' Same as above,but replaced 'b' with a '.'

Browser("title:=/w+/D+/w+ours").Page("title:=/w+/D+/w+ours").Image("file name:=./w+2/....").Highlight

文中推荐了一个学习正则表达式的网站:

http://www.regular-expressions.info/


转自:http://www.52php.cn/article/p-djkwmrhk-bdc.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读