51Testing软件测试论坛

标题: 判断一个link是否存在的写法 [打印本页]

作者: roffer    时间: 2009-5-20 15:44
标题: 判断一个link是否存在的写法
在我的脚本里,如果下面的link不存在,则希望将程序推出当前循环,return -1,然后继续下一个操作,而不希望出现类似这样的erro:Action.c(79): Error -27995: Requested link ("Text=Cash (USD)") not found          [MsgId: MERR-27995]
Action.c(79): web_link("cash") highest severity level was "ERROR", 0 body bytes, 0 header bytes         
[MsgId: MMSG-26388]。

web_link("cash",
"Text=Cash (USD)",
LAST);

我的做法是在这个web_link之前,添加判断
        status =   web_link("cash",
                        "Text=Cash (USD)",
                        LAST);
        lr_message("%d", status);
        if (status == LR_FAIL) {
       
                 lr_error_message ( "Error at agreementID  #%s, no Cash(USD) asset", lr_eval_string ( "{searchAggID}" ) );
                 return 0;
        }

为什么不行呢?
作者: zhysync    时间: 2009-5-20 16:53
好好研究一下web_link这个函数。这是一个模拟鼠标点击的函数,它的返回结果自然是这个操作的结果状态。看看帮助的解释:The web_link function is an action function that emulates a mouse click on the link that is defined by the attributes. web_link can be executed only in the context of a previous operation.
建议你用:web_text_link和web_image_link试试
作者: 蟑螂    时间: 2009-5-20 17:10
好帖子,继续交流




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2