51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1657|回复: 6
打印 上一主题 下一主题

[原创] 【已解决】高手来!句柄(hwnd)问题

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2012-12-12 10:46:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 黑羽祭 于 2012-12-13 09:14 编辑

Browser("micclass:=Browser").OpenNewTab新建一个窗口,如何让他自动获取新窗口的hwnd,求代码!
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

  • TA的每日心情
    无聊
    2018-9-27 10:05
  • 签到天数: 36 天

    连续签到: 1 天

    [LV.5]测试团长

    2#
    发表于 2012-12-12 11:24:02 | 只看该作者
    回复 1# tmdbt100200


        随手写的,没验证,你试试看吧。
    1. Dim newHwnd
    2. Browser("micclass:=Browser").OpenNewTab
    3. newHwnd = Browser("micclass:=Browser","CreationTime:=1").GetROProperty("hwnd")
    4. msgbox newHwnd
    复制代码
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    3#
     楼主| 发表于 2012-12-12 18:58:35 | 只看该作者
    回复 2# 黑羽祭


        谢谢楼主问答,妄确,不愧为楼主,但我想问下,楼主是如何知道用CreationTime:=1这个方法的呢?哪本书里有还是从其他方面得知,望告诉,谢谢
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    无聊
    2018-9-27 10:05
  • 签到天数: 36 天

    连续签到: 1 天

    [LV.5]测试团长

    4#
    发表于 2012-12-13 09:13:10 | 只看该作者
    本帖最后由 黑羽祭 于 2012-12-13 09:14 编辑

    回复 3# tmdbt100200


        妄确是神马?楼主?你这是变相夸自己啊~
        我是以前刚开始玩QTP的时候在对象库里发现的这个属性,然后上网查的的内容
    关于CreationTime,在帮助文档里详细的说明:
    Identifying an Object Using the CreationTime Property
    While learning a browser object, QuickTest assigns a value to the CreationTime identification property. This value indicates the order in which the browser was opened relative to other open browsers. The first browser that opens receives the value CreationTime = 0.

    During the run session, if QuickTest is unable to identify a browser object based solely on its test object description, it examines the order in which the browsers were opened, and then uses the CreationTime property to identify the correct one.

    For example, if QuickTest learns three browsers that are opened at 9:01 pm, 9:03 pm, and 9:05 pm, QuickTest assigns the CreationTime values, as follows: CreationTime = 0 to the 9:01 am browser, CreationTime = 1 to the 9:03 am browser, and CreationTime = 2 to the 9:06 am browser.

    At 10:30 pm, when you run a test or component with these browser objects, suppose the browsers are opened at 10:31 pm, 10:33 pm, and 10:34 pm. QuickTest identifies the browsers, as follows: the 10:31 pm browser is identified with the browser test object with CreationTime = 0, 10:33 pm browser is identified with the test object with CreationTime = 1, 10:34 pm browser is identified with the test object with CreationTime = 2.

    If there are several open browsers, the one with the lowest CreationTime is the first one that was opened and the one with the highest CreationTime is the last one that was opened. For example, if there are three or more browsers open, the one with CreationTime = 2 is the third browser that was opened. If seven browsers are opened during a recording session, the browser with CreationTime = 6 is the last browser opened.

    If a step was created on a Browser object with a specific CreationTime value, but during a run session there is no open browser with that CreationTime value, the step will run on the browser that has the highest CreationTime value. For example, if a step was created on a Browser object with CreationTime = 6, but during the run session there are only two open browsers, with CreationTime = 0 and CreationTime = 1, then the step runs on the last browser opened, which in this example is the browser with CreationTime = 1.
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    5#
    发表于 2012-12-13 10:17:57 | 只看该作者
    --补充--
    可以通过两种方式获取browser的hwnd
    Browser("micclass:=Browser","CreationTime:=1").GetROProperty("hwnd")
    Browser("micclass:=Browser","CreationTime:=1").Object.HWND
    如果是通过vbs进行对象的判断,使用第二个;如果使用qtp进行对象识别(QTP对象操作),则使用第一个。
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    郁闷
    2015-11-30 21:04
  • 签到天数: 6 天

    连续签到: 1 天

    [LV.2]测试排长

    6#
    发表于 2012-12-13 10:43:26 | 只看该作者
    回复 2# 黑羽祭
    版主,我的OpenNewTab为什么就不好使呢。。。环境:QTP11.0+Win7+IE8.0
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    无聊
    2018-9-27 10:05
  • 签到天数: 36 天

    连续签到: 1 天

    [LV.5]测试团长

    7#
    发表于 2012-12-13 11:08:49 | 只看该作者
    回复 6# slxmikesong


    你试试开一个IE页面的情况下运行   
    browser(":=").OpenNewTab
    如果还不行,就写详细一些,然后发个贴吧
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

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

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

    GMT+8, 2024-11-22 21:53 , Processed in 0.078296 second(s), 27 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

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