Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to run multiple threads concurrently for Automated Selenium testing?
    primarykey
    data
    text
    <p>I have one web application from which I can start respective testing process which is in another Java app. I am using Socket Programming for communication between Web app and Java app.</p> <p>When I request for specific process from web app then SocketServer from Java app hears request and start one thread for Testing process. Testing process will initialize FirefoxDriver and start browser and do further test process.</p> <p>My problem is, when I request for another process with different process name then It again creates second thread and start firefox browser but this time it is not considering my second process, it started to do same process which is first thread have.</p> <p>I do not understand what to do...For every process I created a new thread but further it will doing same process. My inputs are correctly received at Java app. Please help me How can I do the concurrent thread safe processing? I am using GWT,Java, Seleniun FirefoxDriver.</p> <p>here is the Server code which is running in background and listen client request:</p> <pre><code>static final int PORT = 6789; public static void main(String args[]) { ServerSocket serverSocket = null; Socket socket = null; try { InitializeApplication application = new InitializeApplication(); application.initialize(); serverSocket = new ServerSocket(PORT); } catch (Exception e) { log("Exception in SocketServerExecutor !!!",e); } while (true) { try { socket = serverSocket.accept(); } catch (Exception e) { log("Exception in SocketServerExecutor !!!",e); } Thread thread = new Thread(new SocketServerThread(socket)); thread.start(); } } </code></pre> <p>and this is the Thread which start process:</p> <pre><code> private Socket client; public SocketServerThread(Socket serverSocket) { this.client = serverSocket; } /** * Starts appropriate process depending on process name from input. * Input string contains: * process name */ public void run() { DataOutputStream outputStream = null; String param = null; try{ log("Just connected to "+ client.getRemoteSocketAddress()); try { while ((param = in.readUTF()) != null){ log("got parameteres from client (i.e. from web app): "+param); break; } } catch (Exception e) { } if(param!=null &amp;&amp; !param.isEmpty()){ String process = params[0]; ProcessManager manager = new ProcessManager(); if(process.equals("testUser")) manager.startUserProcess(process); else if(process.equals("testCustomer")) manager.startCustomerProcess(process); } }catch(Exception exc){ if(exc instanceof SocketTimeoutException) log("Socket timed out! [SocketServerThread]",exc); else if(exc instanceof BindException) log("BindException in SocketServerThread !!!",exc); log(Level.SEVERE, "Exception in SocketServerThread !!!",exc); } } </code></pre> <p>and this is ProcessManager:</p> <pre><code>public void starUserProcess(String siteName) { ExecutorService executerService = null; try{ Callable&lt;Object&gt; callable = new ProcessThread(siteName); executerService = Executors.newCachedThreadPool(); Future&lt;Object&gt; future = executerService.submit(callable); future.get(); log("[ProcessManager] Process completed for "+process); System.exit(0); }catch (Exception e) { log("[ProcessManager]::Exception"); log(ex); } } </code></pre> <p>ProcessThread will initialize all required things and Firefox browser and start process. Client is new every time which contains input.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload