51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1463|回复: 3
打印 上一主题 下一主题

[原创] function:如何编写验证网页上的filter功能

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2012-3-16 06:24:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
现有1个scenario 要编写function 来 验证网页上filter 功能是否正常. 这样的function 怎么样写比较好?
谢谢大家的指教
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
 楼主| 发表于 2012-3-16 18:10:25 | 只看该作者
waitting for the answers
回复 支持 反对

使用道具 举报

该用户从未签到

3#
发表于 2012-3-17 14:21:02 | 只看该作者
例如要过滤回帖内容中的“你好”2个字

set objChildobjects="此处是父窗口".Childobjects()
strInputContent="你好,楼主真是好人你好,呵呵你好啊啊" '要回复的内容
filtestr = "你好"  '要过滤的内容

msgbox  checkfilter(objChildobjects,strInputContent,filtestr)  '调用测试函数

set objChildobjects=nothing

function checkfilter(objChildobjects,strInputContent,filtestr)
  dim i
  i=0
do while i<objChildobjects.count
   if  objChildobjects(i).geroproperty("micclass")="webeidt" and objChildobjects(i).geroproperty("text")="回帖编辑框"  then  '类似这样判断  因为不知道LZ的具体测试对象
   Childobjects(i).set strInputContent
          i=0
      do while i<objChildobjects.count

          if  objChildobjects(i).geroproperty("micclass")="webbutton" and objChildobjects(i).geroproperty("text")="发表回复"  then
               objChildobjects(i).click
                 exit do
               end if
            i=i+1
        loop
     exit do
  end if
    i=i+1
   loop

dim getstr

getstr=""
  i=0
do while i<objChildobjects.count
   if  objChildobjects(i).geroproperty("micclass")="webeidt" and objChildobjects(i).geroproperty("text")="显示区域"  then  
           
       getstr= objChildobjects(i).geroproperty("text")

           exit do

     end if
i=i+1
loop
'以上假设所有操作对象均存在
     if not  instr(getstr,filtestr,1) then
            checkfilter=1

    else
checkfilter=0

end if
         
end function
回复 支持 反对

使用道具 举报

该用户从未签到

4#
 楼主| 发表于 2012-3-17 18:32:30 | 只看该作者
回复 3# 正在更新

非常感谢你的回答。 我现在就去qtp 中试试
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /2 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-6-15 11:30 , Processed in 0.074239 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表