# Generic procedure to start
an application on Windows.
# We take advantage of the Windows+r key to open the Run box.
procedure startApp {
Press
Windows+r
wait=3s
Typeline "{1}" wait=4s
}
#
Start calculator, type "5+5" followed by Enter
# and take a screen shot.
startApp calc
Typeline
"5+5"
wait=2s
Screenshot
calculator_result.jpg
desc="Result
of 5+5" |
|
------------------------->

Conversion to Java (video)
|
|
import com.tplan.robot.scripting.DefaultJavaTestScript; import com.tplan.robot.scripting.JavaTestScript; import java.io.File; import java.io.IOException;
public class Calculator extends DefaultJavaTestScript implements JavaTestScript {
public void test() { try { startApp("startApp", "calc"); typeLine("5+5", "2s"); screenshot(new File("calculator_result.jpg"), "Result of 5+5"); } catch (IOException ex) { ex.printStackTrace(); } }
private int startApp(String... args) throws IOException { press("Windows+r", "3s"); typeLine(""+args[1], "4s"); return getContext().getExitCode(); } }
|