51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 3226|回复: 17
打印 上一主题 下一主题

[原创] Fail to Run

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2005-11-26 11:07:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Can someone help me to verify my code? I nearly CRAZY

  1. SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "http://xxxx.com"

  2. Set main = Description.Create()
  3. Set web = Description.Create()
  4. Set staffid = Description.Create()
  5. Set staffname = Description.Create()
  6. Set costcentre = Description.Create()
  7. Set table = Description.Create()
  8. Dim question

  9. main("title").Value = "http://xxxx.com"
  10. web("url").Value = "http://xxxx.com"
  11. staffid("name").Value = "staffid"
  12. staffname("name").Value = "name"
  13. costcentre("name").Value = "cost_centre"

  14. Set  wb = Browser(main).Page(web)

  15. Fn_AboutYou()
  16. Fn_Check()

  17. Public function Fn_AboutYou
  18.         wb.WebEdit(staffid).Set DataTable("id", dtLocalSheet)
  19.         wb.WebEdit(staffname).Set DataTable("name", dtLocalSheet)
  20.         wb.WebList(cost_centre).Select DataTable("cost_centre", dtLocalSheet)
  21. End Function

  22. Public function Fn_Check
  23.         For i =1 to 15
  24.                 table("name").Value = "q"&i
  25.                 question =wb.WebTable(table).GetROProperty("innertext")
  26.                 MsgBox(question)
  27.         Next
  28. End Function
复制代码


When I ran the code, it said:

  1. Cannot find the "WebEdit" object's parent "Browser" (class Browser). Verify that parent properties match an object currently displayed in your application.
复制代码


I already confirm the properties/types of all the elements. But it still failed to run.
PLease help me~~~~

If you have any query, feel free to ask.

Many Thanks.

[ 本帖最后由 kkfhk 于 2005-11-26 11:14 编辑 ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2005-11-26 14:06:38 | 只看该作者
主要原因还是Browser(main) QTP认不出来,检查一下标题是否有改变呢?也可以debug查看试试。
回复 支持 反对

使用道具 举报

该用户从未签到

3#
发表于 2005-11-26 18:04:38 | 只看该作者
原因:提供的对象信息不全,还有对象的信息不正确以及识别方式存在问题。

请参考下面的代码,以下代码已经调试通过。



  1. SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "http://www.google.com"

  2. Set main = Description.Create()
  3. Set web = Description.Create()
  4. Set staffid = Description.Create()
  5. Set staffname = Description.Create()

  6. main("name").Value="Google"
  7. web("url").value="http://www.google.com/intl/zh-CN"

  8. staffid("name").Value = "q"
  9. staffid("type").Value = "text"
  10. staffid("html tag").Value = "INPUT"

  11. staffname("name").Value = "Google 搜索"
  12. staffname("type").Value = "submit"
  13. staffname("html tag").Value = "INPUT"

  14. Set  wb = Browser(main).Page(web)

  15. Fn_AboutYou()
  16. Fn_Check()

  17. Public function Fn_AboutYou
  18.         wb.WebEdit(staffid).Set "软件测试"
  19. End Function

  20. Public function Fn_Check
  21.       wb.WebButton(staffname).Click
  22. End Function
复制代码
回复 支持 反对

使用道具 举报

该用户从未签到

4#
 楼主| 发表于 2005-11-28 09:45:54 | 只看该作者
It seems the "Browser" & "Page" 's properties same as me.
I think the error should occur again.

原帖由 海龙 于 2005-11-26 18:04 发表
原因:提供的对象信息不全,还有对象的信息不正确以及识别方式存在问题。

请参考下面的代码,以下代码已经调试通过。


[code]
SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE&qu ...
回复 支持 反对

使用道具 举报

该用户从未签到

5#
发表于 2005-11-28 11:18:00 | 只看该作者
你的这个是不是有一个 action要执行好多次呢,你有没有注意观察,在运行的时候,输入第二次 参数的时候,就出现了问题呢?如果是那样的话,有可能是录制过程出现了错误,在录制的时候,第一次输入完信息,应让他返回那个页面才可以。你试一下吧!
回复 支持 反对

使用道具 举报

该用户从未签到

6#
发表于 2005-11-28 11:28:51 | 只看该作者

这些脚本,我怎么从来没见过,这是自己写的吗?

可以给解释解释吗?
回复 支持 反对

使用道具 举报

该用户从未签到

7#
发表于 2005-11-28 11:41:50 | 只看该作者
手写的代码
回复 支持 反对

使用道具 举报

该用户从未签到

8#
发表于 2005-11-28 12:00:24 | 只看该作者
我觉得 应该是你开头定义WebEdit
有问题!
你可以用SPY先查看WebEdit控件,然后换另一个试试!
自己写控件就是这样的麻烦,但很灵活!
回复 支持 反对

使用道具 举报

该用户从未签到

9#
 楼主| 发表于 2005-11-28 13:49:48 | 只看该作者
原帖由 GIGI456 于 2005-11-28 11:18 发表
你的这个是不是有一个 action要执行好多次呢,你有没有注意观察,在运行的时候,输入第二次 参数的时候,就出现了问题呢?如果是那样的话,有可能是录制过程出现了错误,在录制的时候,第一次输入完信息,应让他返 ...



The action will only run for 1 time. Also, I already use the spy to get the properties of "Browser", "age", "WebEdit"....etc.
Each of them I also define all the object more than 1 properties.
But the error still occurs.
However, if I record it, it can playback the script.~~~~
But doesn't matter, thx all of your help.



^_^

[ 本帖最后由 kkfhk 于 2005-11-28 14:11 编辑 ]
回复 支持 反对

使用道具 举报

该用户从未签到

10#
发表于 2005-11-28 14:44:58 | 只看该作者
原帖由 kkfhk 于 2005-11-28 13:49 发表



The action will only run for 1 time. Also, I already use the spy to get the properties of "Browser", "Page", "WebEdit"....etc.
Each of them I also define all th ...



你的脚本中,因为没有提供对象足够的信息,所以导致QTP无法根据这些信息找到对象。父对象和子对象的描述都存在这样的问题。

当你录制时,QTP已经记录了完整而足够的对象信息,所以录制的脚本可以回放成功。
回复 支持 反对

使用道具 举报

该用户从未签到

11#
 楼主| 发表于 2005-11-28 16:24:43 | 只看该作者
But I tried to provide more properties for each object like their Class Name, name, title, url, htmltag, etc.

But still fail.

Should I ignore this problem by using Object Repository+ Descriptive Program [DP] rather than only DP?

Please adivse.

================================================================

Moreover, I have an othe question would like to ask:

If I have a WebTable, contained 5 rows, Question row and 4 answer rows.
If I only want to retreive the Question innertext. How can I finish it?
I tried to use GetROProperty of WebTable's innerText, but it return all the question and answer fields for me.

Please help~~~:,(:,(:,(

[ 本帖最后由 kkfhk 于 2005-11-28 16:29 编辑 ]
回复 支持 反对

使用道具 举报

该用户从未签到

12#
发表于 2005-11-28 16:36:00 | 只看该作者
从你说用录制而不是手写没有错误来看.就可以在判定之前说的定义WebEdit的问题
现在你主要再重新定义一下WebEdit,你可以选择唯一的信息进行定义
这个可以防止同一个页面有两个WebEdit,QTP不知道指认哪个!
另外一个.不明白为什么要自己手写!
这样很麻烦,又很浪费时间!是为了方便日后修改是吗?
回复 支持 反对

使用道具 举报

该用户从未签到

13#
 楼主| 发表于 2005-11-28 16:54:35 | 只看该作者
QA_BAY,

The web I used to test have only 2WebEdit, 1WebList, and 15MC with WebRadioButton.

And why do I use Descriptive Program rather than record.
Yes. It will make us more efficieny to maintaince.
And
It is because the 15MC will randomly generate from 50MC every browser refresh with different sequence.
Also, the answer of MC will have different sequence too.
For example,

Q1. How old are you?
Ans:  1. 10
         2. 20
         3. 30
         4. 40
Browser Refresh
Q2. How old are you?
Ans:  1. 30
         2. 10
         3. 40
         4. 20
回复 支持 反对

使用道具 举报

该用户从未签到

14#
发表于 2005-11-28 17:30:12 | 只看该作者
请看脚本中对错误的解释



SystemUtil.Run "C:\Program Files\Internet Explorer\IEXPLORE.EXE", "http://xxxx.com"

Set main = Description.Create()
Set web = Description.Create()
Set staffid = Description.Create()
Set staffname = Description.Create()
Set costcentre = Description.Create()
Set table = Description.Create()
Dim question

main("title").Value = "http://xxxx.com"
web("url").Value = "http://xxxx.com"
这个两个属性值不一定正确,请用Object Spy查看后,有正确的值替代

staffid("name").Value = "staffid"
staffname("name").Value = "name"
costcentre("name").Value = "cost_centre"
这三个都是WebEdit对象,只有name属性是不够的,只通过这个属性无法识别对象。
请看我写的脚本,使用了name、type、html tag三个属性值,通过这些属性才能识别对象。
    staffid("name").Value = "q"
    staffid("type").Value = "text"
    staffid("html tag").Value = "INPUT"


Set  wb = Browser(main).Page(web)

Fn_AboutYou()
Fn_Check()

Public function Fn_AboutYou
        wb.WebEdit(staffid).Set DataTable("id", dtLocalSheet)
        wb.WebEdit(staffname).Set DataTable("name", dtLocalSheet)
        wb.WebList(cost_centre).Select DataTable("cost_centre", dtLocalSheet)
End Function

Public function Fn_Check
        For i =1 to 15
                table("name").Value = "q"&i
                question =wb.WebTable(table).GetROProperty("innertext")
                MsgBox(question)
        Next
End Function
回复 支持 反对

使用道具 举报

该用户从未签到

15#
发表于 2005-11-29 14:46:05 | 只看该作者
这种手法的方式,还没试过呢,学习img.....顶
回复 支持 反对

使用道具 举报

该用户从未签到

16#
发表于 2005-12-8 17:40:35 | 只看该作者
论坛管理员高!,佩服,学习中
回复 支持 反对

使用道具 举报

该用户从未签到

17#
发表于 2005-12-21 15:49:28 | 只看该作者
虽然不太明白kkfhk 说什么.   (E文理解起来不是很清楚)
但是管理员回答的很仔细,学习ing......
回复 支持 反对

使用道具 举报

该用户从未签到

18#
发表于 2005-12-22 13:54:11 | 只看该作者
又学到一点新东西。
回复 支持 反对

使用道具 举报

本版积分规则

关闭

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

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

GMT+8, 2024-9-21 19:31 , Processed in 0.090690 second(s), 28 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

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