int web_find( const char *StepName, <Attributes and Specifications list>, char *searchstring, LAST ); 
 
StepName:步骤名称,必选
Attributes and Specifications list:属性列表,可选
    expect:定义返回成功的标准,found(默认)-表示找到字符串返回成功,notfound-表示未找到字符串返回成功
    Matchcase:是否区分大小写,yes-表示区分大小写,no(默认)-表示不区分大小写
    report:定义结果报告的内容,success-只包含成功,failure-只包含失败,always(默认)-包含所有
    onfailure=abort:失败则终止脚本运行
    RightOf:从指定字符串的右边开始查找
    LeftOf:从指定字符串的左边开始查找
searchstring:查找的字符串,格式为:"What=stringxyz",必选
LAST:结束标记,必选
 
 

WebTours登录后页面展示的内容:

Welcome, jojo, to the Web Tours reservation pages.
Using the menu to the left, you can search for new flights to book, or review/edit the flights already booked. Don't forget to sign off when you're done!
 
 
1、web_find之expect属性:
Action()
{ web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t34.inf",
"Mode=HTML",
EXTRARES,
"Url=../favicon.ico", "Referer=", ENDITEM,
LAST); web_submit_form("login.pl",
"Snapshot=t35.inf",
ITEMDATA,
"Name=username", "Value=jojo", ENDITEM,
"Name=password", "Value=bean", ENDITEM,
"Name=login.x", "Value=52", ENDITEM,
"Name=login.y", "Value=11", ENDITEM,
LAST); web_find("web_find",
//期望返回成功的结果是找到字符串,因当前页面包含要查找的字符串,故返回结果是成功
"expect=found",
//当前页面中查找字符串"jojo"
"What=jojo",
LAST); web_find("web_find",
//期望返回成功的结果是未找到字符串,因当前页面包含要查找的字符串,故返回结果是失败
"expect=notfound",
//当前页面中查找字符串"jojo"
"What=jojo",
LAST); return ;
}

代码执行结果:

Action.c(24): "web_find" successful. 1 occurrence(s) of "jojo" found (RightOf="", LeftOf="")   [MsgId: MMSG-27196]

Action.c(24): web_find was successful   [MsgId: MMSG-26392]

Action.c(31): Error -27195: "web_find" failed. 1 occurrence(s) of "jojo" found (RightOf="", LeftOf="")   [MsgId: MERR-27195]

Action.c(31): web_find highest severity level was "ERROR"   [MsgId: MMSG-26391]

 
 
2、web_find之Matchcase属性:
Action()
{ web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t34.inf",
"Mode=HTML",
EXTRARES,
"Url=../favicon.ico", "Referer=", ENDITEM,
LAST); web_submit_form("login.pl",
"Snapshot=t35.inf",
ITEMDATA,
"Name=username", "Value=jojo", ENDITEM,
"Name=password", "Value=bean", ENDITEM,
"Name=login.x", "Value=52", ENDITEM,
"Name=login.y", "Value=11", ENDITEM,
LAST); web_find("web_find",
//区分大小写,因当前页面不包含JOJO,故返回结果是失败
"Matchcase=yes",
//当前页面中查找字符串"JOJO"
"What=JOJO",
LAST); web_find("web_find",
//不区分大小写,因当前页面包含jojo,故返回结果是成功
"Matchcase=no",
//当前页面中查找字符串"JOJO"
"What=JOJO",
LAST); return ;
}

代码执行结果:
Action.c(24): Continuing after Error -27195: "web_find" failed. 0 occurrence(s) of "JOJO" found (RightOf="", LeftOf="")   [MsgId: MERR-27195]
Action.c(24): web_find highest severity level was "continue on error"   [MsgId: MMSG-26391]
Action.c(24): Continuing after error in Vuser script.
Action.c(31): "web_find" successful. 1 occurrence(s) of "JOJO" found (RightOf="", LeftOf="")   [MsgId: MMSG-27196]
Action.c(31): web_find was successful   [MsgId: MMSG-26392]
 
 
3、web_find之onfailure属性:
Action()
{ web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t34.inf",
"Mode=HTML",
EXTRARES,
"Url=../favicon.ico", "Referer=", ENDITEM,
LAST); web_submit_form("login.pl",
"Snapshot=t35.inf",
ITEMDATA,
"Name=username", "Value=jojo", ENDITEM,
"Name=password", "Value=bean", ENDITEM,
"Name=login.x", "Value=52", ENDITEM,
"Name=login.y", "Value=11", ENDITEM,
LAST); web_find("web_find",
//如果函数返回结果失败,则终止脚本运行,根据运行结果可以发现,第二个web_find没有运行
//注意:Continue on Error 设置了才能看到效果,否则的话,不管是否有该属性都会终止运行
"onfailure=abort",
//当前页面中查找字符串"JOJO"
"What=jojo1",
LAST); web_find("web_find",
//当前页面中查找字符串"JOJO"
"What=jojo",
LAST); return ;
}
 
代码运行结果:
Action.c(24): Fatal Error -27195: "web_find" failed. 0 occurrence(s) of "jojo1" found (RightOf="", LeftOf="")   [MsgId: MERR-27195]
Action.c(24): web_find highest severity level was "FATAL ERROR"   [MsgId: MMSG-26391]
Abort was called from an action.
 
 
4、web_find之LeftOf、RightOf属性:
Action()
{ web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t34.inf",
"Mode=HTML",
EXTRARES,
"Url=../favicon.ico", "Referer=", ENDITEM,
LAST); web_submit_form("login.pl",
"Snapshot=t35.inf",
ITEMDATA,
"Name=username", "Value=jojo", ENDITEM,
"Name=password", "Value=bean", ENDITEM,
"Name=login.x", "Value=52", ENDITEM,
"Name=login.y", "Value=11", ENDITEM,
LAST); web_find("web_find",
//从, to the Web左边查找jojo
"LeftOf=, to the Web",
//从Welcome右边查找jojo
"RightOf=Welcome, ",
"What=jojo",
LAST); return ;
}

代码运行结果:
Action.c(24): "web_find" successful. 1 occurrence(s) of "jojo" found (RightOf="Welcome, ", LeftOf=", to the Web")   [MsgId: MMSG-27196]
Action.c(24): web_find was successful   [MsgId: MMSG-26392]

最新文章

  1. Storm系列(二):使用Csharp创建你的第一个Storm拓扑(wordcount)
  2. CentOS6.5菜鸟之旅:关于搜索的shell命令
  3. 风云CM - 算法分析 &amp; genkey实现
  4. 输入n个数组,数组长度不等,每个数组取出一个数进行组合,求出所有的组合。
  5. poj3258
  6. distance.c
  7. tsunami:一种基于UDP协议的高速传输
  8. Remoting接口测试工具
  9. 基于python3.x,使用Tornado中的torndb模块操作数据库
  10. win10下Anaconda 2 和 3 共存安装,并切换jupyter notebook和Pycharm中的对应版本
  11. AES对称加密
  12. Python学习笔记五
  13. pta编程总结2
  14. ubuntu下使用nvm安装nodejs
  15. BASH 基本语法
  16. C++多线程的使用
  17. Docker 开发概述
  18. SpringBoot配置logback
  19. PostgreSQL存储过程(2)-基于PL/PgSQL的存储过程
  20. servlet07

热门文章

  1. shell脚本特殊变量与变量子串相关知识
  2. windows之cmd常用命令
  3. SQL group by分组查询
  4. APP开发者如何从应用程序中赚钱?
  5. [CSP-S模拟测试]:赤壁情(DP)
  6. 前端每日实战:38# 视频演示如何用纯 CSS 创作阶梯文字特效
  7. mysql经典面试题之学生成绩表
  8. PHP缓存技术OB系统函数(总结)
  9. 【ngx-ueditor】百度编辑器按下Shift键不触发contentChange事件
  10. jQuery基础教程之is()方法和has() 方法