Friday, March 9, 2012

Simple Rest Server - Solution For Tool Integration across the Machines :-

I got an opportunity to integrate Sikuli and Selenium RC (perl) , provided Hudson is executed in a CentOS machine.
We do not want to have Hudson slave to be on windows/ubuntu machine for test case execution. Execution can be handled in Selenium by giving Server URL in the hudson code base.
We wanted to have a similar approach for Sikuli.
A simple Rest(using Java Restlet API) server is written in the machine which accepts http request with parameters passed as actions, we can perform sikuli actions based on the parameter ,
below is the code which will achieve that...

public class sikuliActionServer extends ServerResource {

public static void main(final String[] args) throws Exception {


final Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
final Router router = new Router(component.getContext().createChildContext());
router.attach("/sikuli", RestletServerTest.class);
component.getDefaultHost().attach("/app", router);
component.start();


}


@Get
public String performSikuliActions() {


String param = getQuery().getFirstValue("command");
Screen screen = new Screen();

//parse the parameter and perform Sikuli Actions

return "PASS"
}

Start the rest server and use Selenium or wget or LWP to get the action result from the remote machine..






}

Mock URL :- http://{serverIP}:8182/app/sikuli?command=click{img},dblClick{img}

No comments:

Post a Comment