首页 | 互联网 | IT动态 | IT培训 | Cisco | Windows | Linux | Java | .Net | Oracle | 软件测试 | C/C++ | 嵌入式开发 | 存储世界 | 服务器
网络设备 | IDC | 安全 | 求职招聘 | 数字网校 | 网页设计 | 平面设计 | 技术专题 | 电子书下载 | 教学视频 | 源码下载 | 搜索 | 博客 | 论坛
中国IT实验室软件测试频道
Google
首页 资讯动态 测试技术 测试工具 行业软件测试 测试管理 测试下载 经验分享 软件质量 其他技术 RSS订阅 博客 论坛
您现在的位置: 中国IT实验室 >> 软件测试 >> 测试工具 >> Robot >> 正文

用Rational Robot测试有数据关联的Web应用

列表4. 函数getURLByText

string func getURLByText(source, text)
string source, text;
{
    int startText, startA, startHref;
    string remainingText, beforeText, aOpenText, hrefText, url;
    string pattern;
    pattern = "([ \\t\\n\\r]*\"(([^\"]*)$0)\")|";
    pattern += "([ \\t\\n\\r]*\\'(([^\\']*)$0)\\')|";
    pattern += "([ \\t\\n\\r]*(([^ \\t\\n\\r]*)$0)[ \\t\\n\\r>])";
    remainingText = source;
    while (1) {
        startText = strstr(remainingText, text);
        if (0 == startText) {
            break;
        } else {
   beforeText = substr(remainingText, 1, startText - 1);
   startA = 0;
// Find the position of the last occurrence of "', beforeText))
{ // The anchor does enclose specified text. if (match( '([Hh][Rr][Ee][Ff][ \t\n\r]*=)$0', beforeText, &hrefText)) { // Check the location of the found "href". startHref = strstr(beforeText, hrefText); if (startHref < strstr(beforeText, ">")) { // Now try to extract the URL if (match( pattern, substr( beforeText, startHref + strlen(hrefText), strlen(beforeText)), &url)) { return url; } } } } } } remainingText = substr( remainingText, startText + strlen(text), strlen(remainingText)); } return ""; }

        列表5中定义的函数“getURLByTextEx”提供了类似但更强大的功能。它允许使用VU语言所支持的正则表达式来指定目标Anchor标签所围绕的字符串的模式。例如,getURLByTextEx(“

        Hello world!

        , “[Ss]urprise”)将返回“hello1.jsp”。

上一页  [1] [2] [3] [4] [5] [6] [7] 下一页

【责编:michael】

中国IT教育

相关产品和培训
文章评论
 专题推荐

 ·建立可全面监控Squid代理服务器
 ·华为认证题库、模拟器下载专题
 ·嵌入式操作系统Linux资料下载(A)
 ·JAVA的应用编程接口——JAVA API详解…
 ·Linux Shell学习技术专题[上]…
 ·windows Server 2008专区…
 ·WEB开发ASP.NET和PHP、JSP究竟学哪个
 ·五步带你入门XML
 ·零距离接触OCP_Oracle认证体系全攻略
 ·揭秘:网络工程师职业发展路线图
 最近更新
 博客论点
 频道精选
 软件测试频道导航