zoukankan      html  css  js  c++  java
  • QTP的那些事描述性编程和正则表达式的应用(转陈能技老师博客)

    在使用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


    作者:高级测试开发网
    博客地址:https://seniortesting.club
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    Linux
    springboot gateway 动态路由-01
    springboot远程debug调试
    springboot使用策略模式实现一个基本的促销
    springboot swagger2案例
    Tcp三次握手四次挥手个人学习
    springboot使用自定义注解和反射实现一个简单的支付
    java后端使用token处理表单重复提交
    基于redis实现未登录购物车
    java中的VO、PO、BO、DAO、POJO
  • 原文地址:https://www.cnblogs.com/seniortestingdev/p/2365144.html
Copyright © 2011-2022 走看看