Test Complete 9 - Console Automation
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2013
01:38 AM
05-13-2013
01:38 AM
Test Complete 9 - Console Automation
How should I store the text displayed in a Putty client?
4 REPLIES 4
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2013
10:24 PM
05-23-2013
10:24 PM
Hi Denisa,
You can use the wText property to work with the text in your console app. Refer to the "Testing Console Applications - Overview" article for details.
---------
Tanya Yatskovskaya
SmartBear Community and Education Manager
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2013
01:56 AM
11-05-2013
01:56 AM
Hi Tanya,
Am I missing something here? I'm also trying to interact with my puTTY session - but I don't get an object of type "ConsoleWindowClass" under the putty Process (not in Object Browser at least!).... The main "text box" area is:
Sys.Process("putty").Form("172.16.8.52 - PuTTY").Client("172.16.8.52 - PuTTY")
There ARE 2 Window objects immediately below the top level processes - both of type "Panel".... Nothing with a wText property etc available.
Am I missing something here? I'm also trying to interact with my puTTY session - but I don't get an object of type "ConsoleWindowClass" under the putty Process (not in Object Browser at least!).... The main "text box" area is:
Sys.Process("putty").Form("172.16.8.52 - PuTTY").Client("172.16.8.52 - PuTTY")
There ARE 2 Window objects immediately below the top level processes - both of type "Panel".... Nothing with a wText property etc available.
Jack of few trades, master of even fewer...
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2013
04:44 PM
11-07-2013
04:44 PM
Hi Steve,
Try using the following approach: copy the PuTTY window's contents to the clipboard. The following code snippet gets the output of the PuTTY window and prints it to the log to the Additional Info panel:
//...
var w = Sys["Process"]("putty")["Window"]("PuTTY", "*", 1);
w["SystemMenu"]["Click"]("Copy All to Clipboard");
Log["Message"](w["WndCaption"], Sys["Clipboard"]);
//...
As soon as you get the needed text, you can use the indexOf method or a regular expression to find out whether the text matches a specific search pattern. Please see the "C++Script, C#Script - Working With Strings" article for information on these features and some sample scripts.
---------
Tanya Yatskovskaya
SmartBear Community and Education Manager
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2018
02:33 AM
03-04-2018
02:33 AM
Created a Function in python which will capture the contents to clipboard and return the results as an array
@TanyaYatskovskawrote:
Hi Steve,
Try using the following approach: copy the PuTTY window's contents to the clipboard. The following code snippet gets the output of the PuTTY window and prints it to the log to the Additional Info panel:
//...
var w = Sys["Process"]("putty")["Window"]("PuTTY", "*", 1);
w["SystemMenu"]["Click"]("Copy All to Clipboard");
Log["Message"](w["WndCaption"], Sys["Clipboard"]);
//...
As soon as you get the needed text, you can use the indexOf method or a regular expression to find out whether the text matches a specific search pattern. Please see the "C++Script, C#Script - Working With Strings" article for information on these features and some sample scripts.
#*****************************************************************************
# def name: GetPuttyText
#
# Description: Gets putty txt from terminal and returns contents.
#
# Inputs: sXTerm = Terminal Name
#
# Outputs: Captured data from screen
#
# Limitations: None
#
# Examples: GetPuttyText(sXTerm)
#
#*****************************************************************************
def GetPuttyText (sXTerm):
# Create Putty object
w = Sys.Process("putty").Window("PuTTY", sXTerm, 1)
w.Restore()
w.Activate()
# Capture data to clipboard
w.SystemMenu.Click("Copy All to Clipboard")
sScreen = Sys.Clipboard
#Log Putty window contents
Log.Message(sScreen)
# Put contents into an array
aScreen = sScreen.splitlines()
# Clean up array and remove blank lines
aScreen = [s and s.strip() for s in aScreen]
aScreen = list(filter(None, aScreen))
# Clear Scrollback in putty
w.SystemMenu.Click("Clear Scrollback")
return aScreen
# GetPuttyText
