How to send input to command line programs

2,558 views
Skip to first unread message

David Genest

unread,
Jan 9, 2017, 2:52:51 PM1/9/17
to robotframework-users
I am using robotframework to test a command line that needs user input (a simple "press any key to continue" prompt).

Is there a way to send keys to a waiting process using core (or library) robotframework ?

Thanks,

David.

Pekka Klärck

unread,
Jan 9, 2017, 4:48:57 PM1/9/17
to david....@gmail.com, robotframework-users
Hi,

I don't think there's a real built-in way. You can, however, run
processes using the Process library [1] and should be able to get an
access to the stdin of the started process and even write to it.
Having a separate keyword in the Process library to support writing to
stdin would be nice. I think there were some non-trivial design
decisions to be made and that's why it wasn't added initially, but I'm
fairly certain adding it wouldn't be overly complicated.

[1] http://robotframework.org/robotframework/latest/libraries/Process.html

Cheers,
.peke
> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to robotframework-u...@googlegroups.com.
> To post to this group, send email to robotframe...@googlegroups.com.
> Visit this group at https://groups.google.com/group/robotframework-users.
> For more options, visit https://groups.google.com/d/optout.



--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

David Genest

unread,
Jan 10, 2017, 3:39:45 PM1/10/17
to robotframework-users, david....@gmail.com
Thank you for your fast response.

For the time being, I have managed to use the shell to output a key:

Run Process   echo \| call my_batch_file_needing_input.bat  shell=True


But the development you propose would be interesting to interact more closely (ala Send Keys of Selenium) but with command line programs.

We may be able to do this development if the need arises again.

Thanks for the robotframework!

D.

On Monday, 9 January 2017 16:48:57 UTC-5, Pekka Klärck wrote:
Hi,

I don't think there's a real built-in way. You can, however, run
processes using the Process library [1] and should be able to get an
access to the stdin of the started process and even write to it.
Having a separate keyword in the Process library to support writing to
stdin would be nice. I think there were some non-trivial design
decisions to be made and that's why it wasn't added initially, but I'm
fairly certain adding it wouldn't be overly complicated.

[1] http://robotframework.org/robotframework/latest/libraries/Process.html

Cheers,
    .peke


Alexander Povar

unread,
May 31, 2019, 6:06:03 AM5/31/19
to robotframework-users
Could you please share more details about how you've managed to find a solution?


Run Process   echo \| call my_batch_file_needing_input.bat  shell=True

here you start your bat file in second argument "call my_batch_file_needing_input.bat", but then when it asks for some input you pass the input as "echo" which is the first agrument? 
But it doesn't seem to work that way.

Wlad

unread,
May 31, 2019, 9:18:04 PM5/31/19
to pova...@gmail.com, robotframework-users
Just some quick ideas



With this I was able to automate interactive shell/terminal dialogs.

Both can be used as is or wrapped in a custom RF library.

Cheers

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
Reply all
Reply to author
Forward
0 new messages