Hi everyone, I am a QA guy and I use watir for testing web applications.
In my testing I sometimes have to work on a Windows application also.
Using WIN32OLE, I am able to access the Windows application and perform
actions in it by sending keystrokes, text, etc. I am able to perform the
task that I need to but it would be nicer if I could verify that
confirmation message is shown in the application when my task is
I am wondering if there is a way to capture the text in the window and
write it to a text file.
This is the code I use to access the application
#create an instance of the Wscript Shell object:
wsh = WIN32OLE.new(‘Wscript.Shell’)
#activate the window identifying it with title
#Here you enter your login Id and Password
Here I tried the following, but it didn’t work.
Open up a notepad document.
Do ctrl+a, and ctrl+c in the first window.
Then go to the notepad document and do ctrl+v to paste the text that is
captured from the application.
If I manually execute the steps listed above,I am able to copy the text.
But the same steps executed through the script do not produce the
#Open up a notepad document
shell.ShellExecute(‘notepad.exe’, ‘’, ‘’, ‘open’, 1)
#activate the first window again because I just opened a notepad and
focus #might have been lost
#Control + A to grab all text in the application window
#Control + C to copy the text
#now shift focus to the notepad document
#Control + V to paste text captured from the app to the notepad
What I tried is just a long shot and it didn’t work. Is there any other
way to capture text from the windows applicaiton? Can someone please
share their code if they have been able to perform this?