/** * Wraps the passed message up in an HTTP 200 response, with the Content-type * header set to application/json * @param message message to wrap up as the response * @return The passed message, wrapped up in an HTTP 200 response, * encoded in UTF-8 */ private byte[] fillTwoHundredWithJson(String message) { return fillTwoHundred(message, "application/json; charset=UTF-8"); }
/** * Executes the passed command * @param command command to execute * @return response to command * @throws IllegalStateException if no socket was present */ public ChromeResponse execute(Command command) throws IOException { sendCommand(command); return handleResponse(command); }
/** * Kills the started Chrome process and ChromeCommandExecutor if they exist */ protected void stopClient() { chromeBinary.kill(); if (executor != null) { executor.stopListening(); executor = null; } }
private void init() { while (executor == null || !executor.hasClient()) { stopClient(); //TODO(danielwh): Remove explicit port (blocked on crbug.com 11547) this.executor = new ChromeCommandExecutor(9700); startClient(); //In case this attempt fails, we increment how long we wait before sending a command chromeBinary.incrementBackoffBy(1); } //The last one attempt succeeded, so we reduce back to that time chromeBinary.incrementBackoffBy(-1); }
List<Object> arr = new ArrayList<Object>(jsonArray.length()); for (int i = 0; i < jsonArray.length(); i++) { arr.add(parseJsonToObject(jsonArray.get(i)));
return parseResponse(resultBuilder.toString());
socket.getOutputStream().write(fillTwoHundredWithJson(commandStringToSend)); socket.getOutputStream().flush(); } finally {
parameters); try { return executor.execute(command); } catch (Exception e) { if (e instanceof IllegalArgumentException ||
Object parsedValue = parseJsonToObject(value); if (parsedValue instanceof ChromeWebElement) { return new ChromeResponse(-1, ((ChromeWebElement)parsedValue).getElementId());