danguyen avatar image
danguyen asked danguyen posted

How to set automatic respond to prompt?

I try to setup automatic respond to prompt depend on the prompt show up. ex: when the prompt show "Username:" it automactic respond with "guest" ...etc


10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

KumarS avatar image
KumarS answered KumarS posted

I do not understand your question. Is this not the normal problem of logging in to a device? When you telnet to a device, it will give you a login prompt and then you send the username. After that the device will send you password prompt and you send the password.


If you do not know how to write this in an iTest testcase, you should do the following:

1. Create a session profile for your device

2. Click on "Start Capture" button on iTest's main toolbar 

3. Start an interactive session using your session profile to the device

4. Login to the device and issue a few commands

5. Close the session to the device

6. Click on "Finish Capture" button on iTest's main toolbar


This will launch a wizard which will help you create a new testcase which can replay what you did interactively. 


10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

danguyen avatar image danguyen commented ·

I know how to respond to the prompt, but i am using the router, sometime we could not able to control when I need to respond to the special prompt such as passwd or username when for some reason the router is out of privilage mode or reload.  With the cisco ATS csccon tcl library we could set default respond to those prompt and when it saw that prompt it will automatic respond to it.



0 Likes 0 ·
KumarS avatar image KumarS danguyen commented ·

iTest does not have the feature to send command or command sequences based on certain prompts. You will have to write your testcase in such a way that this does not happen.


What we recommend is that you have a "setup" procedure and a "cleanup" procedure which will get the device to the appropriate state before running the actual testcase steps. This way your testcase does not have to worry about trying to deal with getting to the correct privilege mode for execution.


BTW - I will delete your other duplicate thread. 

0 Likes 0 ·
KumarS avatar image KumarS KumarS commented ·

BTW - you can write a procedure in iTest as I mentioned above where you can send a newline as a command and based on the prompt returned, you can have steps to get you to a known state. This procedure will look very similar to what CSCCON is doing in Tcl. Good thing is that once you have written this procedure, you can share it with all your other iTest users in your organization and they can all benefit from it.


For example:

command     s1      <empty command>     <-- on this step, you can right click on the query "prompt()" in the queries view and store the prompt in a variable called "foo"

if     $foo == "config#"


     command  s1   end


Similarly, you can write your procedure to get to the top level prompt and consequently to a known state. You can also write procedures which will take you to the appropriate privilege level. Again, you will have to write this procedure library just once and then you can share it with others. 


0 Likes 0 ·
GregM avatar image GregM KumarS commented ·
Can you create a Session profile Global Rule that calls a procedure (new feature in 3.3) based on prompt() being "Username:", for example?  Or, is calling a procedure only availble from a test case analysis rule?
0 Likes 0 ·
PaulD avatar image PaulD GregM commented ·

It's true that you could add a global rule.  It can check the prompt and, if so, call a procedure to run the step(s) to complete the login if and when it encounters a login prompt.


Global rules are no different than analysis rules added to a specific step.  It's just that these are defined centrally and will be applied to all steps on the corresponding session(s).

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.