RC : Is It possible to Pause the test execution?

565 views
Skip to first unread message

J_QA

unread,
Mar 3, 2010, 9:44:52 AM3/3/10
to Selenium Users
Hi you all !

Well, in my tests cases, I sometimes need to check some
results, at execution time. To do this, I pause temporally the
Selenium Test execution till the user confirms. In Java I use the
classic methods ...

InputStreamReader read = new InputStreamReader(System.in);
BufferedReader buff = new BufferedReader(read);
buff.readLine();

The problem is that the execution doesn't stop when reaches
"buff.readLine()" so It returns "null" ; I tried with Char instead of
String, but It fails too...

Any suggestion??

Many thanks!!

Andrew

unread,
Mar 3, 2010, 11:04:10 AM3/3/10
to Selenium Users
I believe in selenium-ide there is a pause command with a time
attribute. This should get translated to a sleep command in what ever
language you export to. I use PHP and insert sleep(2) quite often to
allow tests to run, let pages fully load, etc. Also, the difference
in speed between an internal server and a hosted live server, those
sleeps need to be adjusted.

darrell

unread,
Mar 3, 2010, 3:17:42 PM3/3/10
to Selenium Users
What I believe you want is to pause until user input. Typically, you
would have waited from input from the user via System.in but Selenium
RC doesn't really have a System.in per-say.

What you can do is add a javascript function to Selenium using the
selenium.addScript() method. Then you can use the selenium.getEval()
to call the javascript function. When you call the function have it
pop open a javascript:alert(). Execution should pause until the user
closes the alert. NOTE: there will be a limit on how long you can
pause. If you pause too long selenium will time out. You might want to
look at selenium.setTimeout() to extend how long you can pause for.

Darrell

J_QA

unread,
Mar 4, 2010, 8:16:04 AM3/4/10
to Selenium Users
Hi you all.

Thank for your responses!! Ok, I will try javascript
solution. It seems to fit very good to my needs.

Thanks!

> > Many thanks!!- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -

darrell

unread,
Mar 4, 2010, 3:14:35 PM3/4/10
to Selenium Users
Got bored:

public String promptForUserInput(String timeout) {
String jsFunctionName = "promptUser()";
String jsFunction = "function " + jsFunctionName + " { var result =
prompt(\"Input: \", \"\"); return result; }";
selenium.setTimeout(timeout);
selenium.addScript(jsFunction, "");
return selenium.getEval(jsFunctionName);
}

A call to this method will pop open an input dialog on the Selenium
window. Whatever the user enters in the dialog will get returned by
this method to the caller, i.e.

String userInput = promptForUserInput("30000");
System.out.println("The user input '" + userInput +"' at the
dialog.");

timeout is in milliseconds.

Reply all
Reply to author
Forward
0 new messages