|
''使用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… |
|