Thursday, 21 March 2013

Selenium Java Client driver working

It is necessary to understand how selenium - java client driver works ?
It communicates to the server using http protocol. In java following code is used to connect to the server



      URL result = new URL(pathToServlet);
      String body = command;
      try {
        uc = getHttpUrlConnection(result);
        uc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
        uc.setInstanceFollowRedirects(false);
        uc.setDoOutput(true);
        wr = getOutputStreamWriter(uc);
        wr.write(body);
        wr.flush();

Java client driver follows following steps to work :
1. Connects to the remote server and sends command to execute.
2.If client sends first command, server check whether the receive command is new, it decides based on session id variable. If session id is null then this is the new command.
3.Server allocates the rc to the command and generates unique session id string and sends back to the client.
4. Now when client sends next command , it also sends session id . Server identifies on which rc command to execute by interpreting the value of session id.

No comments:

Post a Comment