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!!
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
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 -
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.