Manual input from user while running selenium IDE script
Asked Answered
H

9

13

can user is able to give manual input while running selenium IDE script? For ex. If there is name field then can we open input box everytime script runs so that user can give his input for name field?

Let me know whether it is possible or not..

If yes then please suggest me a solution.

Thanks in advance

Huckaback answered 19/1, 2012 at 6:29 Comment(0)
A
18

You can use the following script to invoke a javascript prompt in order to get the value

<tr>
    <td>storeEval</td>
    <td>prompt(&quot;Please enter your FirstName&quot;)</td>
    <td>firstName</td>
</tr>

Then accessing the value is a case of using ${firstName}.

EDIT: Since Selenium IDE 2.5.0, the script needs to look like this:

<tr>
    <td>storeEval</td>
    <td>javascript{prompt(&quot;Please enter your FirstName&quot;)}</td>
    <td>firstName</td>
</tr>
Aldaaldan answered 13/7, 2012 at 11:16 Comment(2)
I don't have version 2.5.0 installed, but according to the other comments, shouldn't it be store instead of storeEval? That would make much more sense.Urion
Moreover, in 3.1.0 (see issue #162) you need to use executeScript with the second argument containing just JS with a return statement (nothing would get stored in the target variable otherwise) instead. Create a new answer now, or is it still acceptable just to extend this one?Urion
G
6

As of 2020 using Selenium IDE 3.16.1, I found the following config worked by the suggested answers above. (I re-answered the question as above answers did not clearly combined all pieces)

Command : execute script

Target : return prompt("Question Text","Default value");

Value : yourVariableName

and fill in the input box by the stored var:

Command : type

Target : (your selector)

Value : ${yourVariableName}
Ginnie answered 17/2, 2020 at 7:42 Comment(0)
T
2

In Selenium IDE 2.8.0: Capture the test session entering the login and password. Edit the Command for each and change from "type" to "waitForText" and remove the values in the Value fields previously stored for login and password. Re-run the saved test script from the IDE.

Trictrac answered 30/9, 2014 at 20:36 Comment(1)
Since I like the accepted solution, this one is better to get fully obfuscated password.Bickering
O
1

Since you specifically asked about Selenium IDE, the answer is no. But you can pause the script and let the user type their name, then have the script continue. I've heard of folks using this technique for handling CAPTCHAs, which of course are not easily automatable.

Osi answered 19/1, 2012 at 11:51 Comment(0)
T
0

You could use the technique suggested here which uses the Selenium WebDriver and Java's BufferedReader. I don't think it can be adapted for Selenium IDE, but the technique should work fine with Selenium RC.

The basic idea is:

  • Issue Selenium commands up to the point where you want to capture user input.
  • Call the following code to capture the user input to a BufferedReader.

    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); reader.readLine();

  • Continue your Selenium commands

(Note, if you are using C#, there is a discussion here on how to use Console.In.ReadLine(); instead of BufferedReader).

Transalpine answered 19/1, 2012 at 9:20 Comment(0)
R
0

Just a minor modification to Stephen Binns response. I'm running Selenium IDE 2.5.0 and my test looks like this:

<tr>
    <td>store</td>
    <td>javascript{prompt(&quot;password&quot;)}</td>
    <td>password</td>
</tr>

Without the javascript{} it wouldn't prompt.

Rig answered 20/5, 2014 at 5:4 Comment(0)
Z
0

The proposed solution works fine for selenium IDE (tested for 2.5)

<tr>
    <td>store</td>
    <td>javascript{prompt(&quot;password&quot;)}</td>
    <td>password</td>
</tr>
Zymometer answered 16/7, 2014 at 5:55 Comment(0)
K
0

Use Thread.Sleep(20000); This will freeze everything for 20s and you can enter whatever fields you want to enter manually in that time period

Kitchenette answered 23/2, 2017 at 17:56 Comment(0)
C
0

none of the accepted answers worked for me. Here is how I solved it:

Create new command (at the top to store my variable that I wanted to use in 30 places.)

  • Command: execute script
  • Target: return "Test Iteration #13"
  • Value: VarName

then in the 30 places I wanted to use that variable. I put this

  • Value: Enter some text into the web input box and my test iteration number is ${VarName}
Conjuncture answered 8/1, 2020 at 23:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.