Ranorex

Getting text from putty via Clipboard

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexStudio
View previous topic :: View next topic  
Author Message
chandu.ise



Joined: 13 Aug 2008
Posts: 11

PostPosted: Fri Aug 29, 2008 6:43 pm    Post subject: Getting text from putty via Clipboard
Hi michael,
Thanxs for ur precious reply.. Sorry michael i couldnt get what u said i was trying the above operation but couldnt succeed... pLe if u dont mind can u please let me know in detail how to select putty system icon for copying it into clipboard...and by the way ple provide me with any help documentation for ranorex studio...will be awaiting for ur reply soon

regards

chandrashekar
Back to top
View user's profile Send private message Send e-mail
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 435

PostPosted: Mon Sep 01, 2008 3:53 pm    Post subject:
Hi chandrashekar,

when you left-click on the small icon on the upper-left corner of Putty's window, the system menu will pop up. There's a menu item called "Copy All to Clipboard" you should click on to copy all the text from the putty session to the clipboard. You can then use the Clipboard.GetText() method to retrieve this text in your code.

Just use the Ranorex Recorder to record the mouse clicks on the menu item and let the recorder generate the code for you.

You can find documentation on RanorexStudio on our homepage:
http://www.ranorex.com/gui-testing-guide/ranorex-studio.html

Regards,
Alex
Ranorex Support Team

PS: If you want to respond to a forum post, you can also click the "PostReply" button instead of creating a new thread for each post. Very Happy
Back to top
View user's profile Send private message Visit poster's website
chandu.ise



Joined: 13 Aug 2008
Posts: 11

PostPosted: Mon Sep 01, 2008 6:25 pm    Post subject: logger info
Thanks Alex,
I never thought that i get reply so soon from this forum...I have one more thing to clarify, let me know how u would invoke putty through renorex studio.. i tried system.diagnostics cmd to invoke as u invoke anyother console...but i couldnt succeed calling PUTTY..could u ple help me out with this issue

regards
chandrashekar
Back to top
View user's profile Send private message Send e-mail
chandu.ise



Joined: 13 Aug 2008
Posts: 11

PostPosted: Tue Sep 02, 2008 6:02 am    Post subject: logger info-putty
Hi Alex,
I tried to do as u said,but i am facing a problem "The name 'Clipboard' doesnt exist in the current context" in the Ranorex studio...could u ple tell me what could be the problem...ple let me know the other version of using clipboard.GetText() command..

regards
chandrashekar
Back to top
View user's profile Send private message Send e-mail
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 435

PostPosted: Tue Sep 02, 2008 11:18 am    Post subject:
You need to specify the exact path to your Putty.exe executable in the Process.Start or Ranorex.Application.StartWindowsApplication method.

The ClipBoard class is in the System.Windows.Forms namespace, so you might need to add a using statement and add a reference to the System.Windows.Forms DLL to your project.

Regards,
Alex
Ranorex Support Team
Back to top
View user's profile Send private message Visit poster's website
chandu.ise



Joined: 13 Aug 2008
Posts: 11

PostPosted: Tue Sep 02, 2008 3:14 pm    Post subject: logger info
Thanks alex,
Finally i got what i was trying
I added the System.windows.Form DLL in to my Reference...i included using system.windows.Form in the program.cs and i used Clipboard.getText()...what exact parameters i need to pass ??...i wanted a particular string to be found out of clipboard Content..how can i search in the Clipboard contents...If you help me out this i could finish off my automation part...please let me know ASAP

regards
chandrashekar
Back to top
View user's profile Send private message Send e-mail
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 435

PostPosted: Tue Sep 02, 2008 3:44 pm    Post subject:
The Clipboard is a .NET framework class, please consult the MSDN documentation for the exact parameters to its methods.
You might also want to take a look at the documentation of the .NET string class that provides methods to search in strings.

Regards,
Alex
Ranorex Support Team
Back to top
View user's profile Send private message Visit poster's website
chandu.ise



Joined: 13 Aug 2008
Posts: 11

PostPosted: Wed Sep 03, 2008 8:23 am    Post subject: pseudo code - putty
Alex,

i have pasted the code for clipboard control...please correct me,i am facing problem executing that...kindly help me out,its very important for me.
steps : assume u have copied the contents from putty now u want to access it in your ranorex studio...just see the try block and let me know what has to be done...bcoz when i execute that piece of code i am getting errors thats y !!!



using System;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Ranorex;

namespace MemCPU
{
class Program
{
[STAThread]
public static int Main(string[] args)
{
int error = 0;
string str;

Logger.LogFileTitle = "Ranorex Log File";
Logger.Initialize(false, "test1.txt", "test1.xml", LogLevel.Info);

try
{
Automation.Test1(); //contains code for executing cmd and copying contents into clipboard

Dim idata as IDataObject = Clipboard.GetDataObject();
if iData.GetDataPresent(DataFormats.Text)
{
str = (String)iData.GetData(DataFormats.Text);
}
else
{
str = "Could not retrieve data off the clipboard.";
}
}
catch (ValidationException)
{
Logger.Error("Validation failed!");
error = -1;
}
Back to top
View user's profile Send private message Send e-mail
chandu.ise



Joined: 13 Aug 2008
Posts: 11

PostPosted: Wed Sep 03, 2008 11:30 am    Post subject: finally solved-putty
Alex,

I have done what ever u suggested me...just check with my code bcoz i was facing trouble with my verification...let me know what i should do...everything works fine..thanks for everything

regards
chandrashekar


IDataObject idata;
Logger.LogFileTitle = "Ranorex Log File";
Logger.Initialize(false, null, "test1.xml", LogLevel.Info);
try
{

Automation.Test1(); // Invoke putty
Automation.Test2(); // mouse move on putty system menu

idata = Clipboard.GetDataObject();
if(idata.GetDataPresent(DataFormats.Text))
{
str = (String)idata.GetData(DataFormats.Text);
Logger.Info("contents copied into Clipboard...");
res = str.Contains(searchstr);
Logger.Info("Finding CPU Model in Clipboard...");
Validate.AreEqual(res,"True","CPU Model String Not present"); }
else {
str = "Could not retrieve data off the clipboard.";
}
Logger.OpenLogViewer();

}
Back to top
View user's profile Send private message Send e-mail
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 435

PostPosted: Thu Sep 04, 2008 9:35 am    Post subject:
You are comparing a bool to a string instance (variable res is obviously a bool, "True" a string). That can't work.

Replace the "True" literal with the true keyword or use the Validate.IsTrue method:
Code: click into code to enlarge
Validate.AreEqual(res,true,"CPU Model String Not present");
// or
Validate.IsTrue(res, "CPU Model String Not present");


Regards,
Alex
Ranorex Support Team
Back to top
View user's profile Send private message Visit poster's website
chandu.ise



Joined: 13 Aug 2008
Posts: 11

PostPosted: Fri Sep 05, 2008 7:07 pm    Post subject: Ranorex
Hi

Thanks for everything...I got what i was trying...


regards
chandrashekar
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexStudio All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum