Is there a class that can control the command window

O

Olivia Dou

I use ruby to do testing.
There are some scenario that look like this:
1) Do some navigation in the web browser and do some operation in it
2) run some command, especially telnet to another machine and then run
the commands
3) operate the browser again
4) run command in the telnet window again.


Now I use watir(Web application Testing in Ruby) to do navigation and
operations in the IE browser, the script look like this:
$ie.goto("http://localhost:8080")
$ie.frame("basefrm").button:)value,"Add Report").click()

And what I need exactly is a similar ruby lib that I can use to write
the script like this style:
cmdWindow.InputCommand("net user newUser /add")

I know that I can use NET::Telnet if I want to do telnet related
operations, and when executing the local commands, may use system(cmd),
but I want to identify the specified command window, and run the
following commands in that window.

I wonder whether I have made the questiong clear.
 
D

Daniel Berger

<snip>

I think you want to use Expect, and the ruby bindings for it

http://wiki.rubygarden.org/Ruby/page/show/RExpect

I dont think Ive ever used it in ruby, but its popular in other
languages

Paul

It doesn't work on Windows afaik, which is the platform I'm guessing
the OP is on based on the mention of IE and Watir. However, there is
win32-console:

http://rubyforge.org/projects/win32console/

Perhaps that can help. There's no test framework built up around it,
though. You'll have to do that yourself. If you do, please create a
project for it. Seems like a good idea. :)

Regards,

Dan
 
O

Olivia Dou

shiwei said:
The following api in Ruby provides you a way to run OS cmd in cmd
window:
exec(command [, arg, ...]);

Rgds,

No, I know exec and system is the method to run OS cmd in cmd window,
but what I need is a class that can represent the command window.

There is a ruby lib vruby that can represent the windows GUI such as
form, dialog, but I didn't see one that can represent the command
window/command prompt.
 
D

Daniel Martin

Olivia Dou said:
No, I know exec and system is the method to run OS cmd in cmd window,
but what I need is a class that can represent the command window.

There is a ruby lib vruby that can represent the windows GUI such as
form, dialog, but I didn't see one that can represent the command
window/command prompt.

It sounds as though you're looking for Win32::Console

http://rubyforge.org/projects/win32console/

It's a little bit out of date, so you'll need to compile a new version
for whatever version of ruby you have.
 
O

Olivia Dou

Daniel said:
It sounds as though you're looking for Win32::Console

http://rubyforge.org/projects/win32console/

It's a little bit out of date, so you'll need to compile a new version
for whatever version of ruby you have.

Thanks, Daniel.
I did a quick research on Win32::Console, and it seems that the
Win32::Console objects represents the console window the ruby script is
run in, isn't it?
If so, I'm afraid it is still not exactly what I want,:(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top