51Testing软件测试论坛

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

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1676|回复: 0
打印 上一主题 下一主题

[原创] 使用QTP的键盘操作

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2009-5-1 22:36:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
''使用QTP的键盘操作
'
''运行CMD
SystemUtil.Run "cmd.exe","","C:\WINDOWS\system32","open"
''输入 ping 51testing.com 字段
Window( "object class:=ConsoleWindowClass" ).Type "Ping www.163.com"
''输入回车
Window( "object class:=ConsoleWindowClass" ).Type micreturn
Window( "object class:=ConsoleWindowClass" ).Type "exit"
''退出
Window( "object class:=ConsoleWindowClass" ).Type  micreturn
txt= Window( "object class:=ConsoleWindowClass" ).GetVisibleText()
''在LOG打印出CMD里面的内容
print txt

Objectives
The objectives of this article are :
Learn how to use DOS command lines in QTP.
Alternative complex tasks.
Alternative .NET methods.
The following content is viewable because you are logged-in.
Thanks for registering!
cmd.exe allows access to the Microsoft Windows Command Prompt, also known as Microsoft DOS.
To-date, cmd.exe is a 32-bit command prompt used in Windows NT, 2000, and XP and offers disk and file maintenance functions to your computer as well as network functions. cmd.exe can be found under System32 folder.
SystemUtil.Run "cmd.exe","","C:\WINDOWS\system32″,"open"

Capture the window by QTP


Window( "object class:=ConsoleWindowClass" )
Print Window( "object class:=ConsoleWindowClass" ).GetROProperty( "title" )
Typing to DOS window
The Type method types the specified string in the window.
Syntax: object.Type KeyboardInput.
KeyboardInput : A String value. The text string and/or constants representing non-alphanumeric keys.

Window( "object class:=ConsoleWindowClass" ).Type "Ping advancedqtp.com"
Window( "object class:=ConsoleWindowClass" ).Type micReturn

Catching the Response
The GetVisibleText method returns the text from the specified area. The text to capture must be visible in the application window when the step runs. The area is defined by pairs of coordinates that designate two diagonally opposite corners of a rectangle.
Syntax : object.GetVisibleText ([Left], [Top], [Right], [Bottom])
txt = Window( "object class:=ConsoleWindowClass" ).GetVisibleText()
print txt

Problems…
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

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

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

GMT+8, 2024-9-25 12:18 , Processed in 0.079634 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

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