问题
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
回答1:
You can use the following script to invoke a javascript prompt in order to get the value
<tr>
<td>storeEval</td>
<td>prompt("Please enter your FirstName")</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("Please enter your FirstName")}</td>
<td>firstName</td>
</tr>
回答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.
回答3:
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.
回答4:
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
).
回答5:
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("password")}</td>
<td>password</td>
</tr>
Without the javascript{} it wouldn't prompt.
回答6:
The proposed solution works fine for selenium IDE (tested for 2.5)
<tr>
<td>store</td>
<td>javascript{prompt("password")}</td>
<td>password</td>
</tr>
回答7:
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
来源:https://stackoverflow.com/questions/8921929/manual-input-from-user-while-running-selenium-ide-script