List of usage examples for org.openqa.selenium WebDriverException WebDriverException
public WebDriverException(Throwable cause)
From source file:org.uiautomation.ios.wkrdp.command.Page.java
License:Apache License
public static JSONObject getCookies() { try {//from w w w . j av a2 s . co m JSONObject cmd = new JSONObject(); cmd.put("method", "Page.getCookies"); return cmd; } catch (JSONException e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.wkrdp.command.Page.java
License:Apache License
public static JSONObject deleteCookie(String cookieName, String domain) { try {//from ww w. ja v a 2 s . c o m JSONObject cmd = new JSONObject(); cmd.put("method", "Page.deleteCookie"); cmd.put("params", new JSONObject().put("cookieName", cookieName).put("domain", domain)); return cmd; } catch (JSONException e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.wkrdp.command.Timeline.java
License:Apache License
public static JSONObject start() { try {/*from w w w . ja v a 2 s . com*/ JSONObject cmd = new JSONObject(); cmd.put("method", "Timeline.start"); return cmd; } catch (JSONException e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.wkrdp.command.Timeline.java
License:Apache License
public static JSONObject stop() { try {/*from w ww . j a va2 s. c om*/ JSONObject cmd = new JSONObject(); cmd.put("method", "Timeline.stop"); return cmd; } catch (JSONException e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.wkrdp.internal.SimulatorProtocolImpl.java
License:Apache License
/** * sends the message to the AUT.//w w w . ja v a 2 s. co m */ protected void sendMessage(String xml) { //System.out.println("sending " + xml); try { byte[] bytes = xml.getBytes("UTF-8"); OutputStream os = socket.getOutputStream(); os.write((byte) ((bytes.length >> 24) & 0xFF)); os.write((byte) ((bytes.length >> 16) & 0xFF)); os.write((byte) ((bytes.length >> 8) & 0xFF)); os.write((byte) (bytes.length & 0xFF)); os.write(bytes); } catch (IOException e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.wkrdp.internal.WebKitRemoteDebugProtocol.java
License:Apache License
public void register() { if (connectionId != null) { throw new WebDriverException("Session already created."); }//w w w . ja va 2 s . co m connectionId = UUID.randomUUID().toString(); Map<String, String> var = ImmutableMap.of("$WIRConnectionIdentifierKey", connectionId); sendSystemCommand(PlistManager.SET_CONNECTION_KEY, var); }
From source file:org.uiautomation.ios.wkrdp.internal.WebKitRemoteDebugProtocol.java
License:Apache License
public void connect(String bundleId) { if (connectionId == null) { throw new WebDriverException("Cannot connect to app " + bundleId + ".Call register first."); }/*from w w w . j av a2 s.co m*/ Map<String, String> var = ImmutableMap.of("$WIRConnectionIdentifierKey", this.connectionId, "$bundleId", bundleId); sendSystemCommand(PlistManager.CONNECT_TO_APP, var); this.bundleId = bundleId; }
From source file:org.uiautomation.ios.wkrdp.internal.WebKitRemoteDebugProtocol.java
License:Apache License
public void attachToPage(int pageId) { String senderKey = generateSenderString(pageId); if (connectionId == null || bundleId == null) { throw new WebDriverException("You need to call register and connect first."); }/* w ww. ja va 2 s . c om*/ Map<String, String> var = ImmutableMap.of("$WIRConnectionIdentifierKey", connectionId, "$bundleId", bundleId, "$WIRSenderKey", senderKey, "$WIRPageIdentifierKey", "" + pageId); sendSystemCommand(PlistManager.SET_SENDER_KEY, var); }
From source file:org.uiautomation.ios.wkrdp.internal.WebKitRemoteDebugProtocol.java
License:Apache License
public synchronized JSONObject sendWebkitCommand(JSONObject command, int pageId) { String sender = generateSenderString(pageId); try {//from w w w .j a v a 2 s .c o m commandId++; command.put("id", commandId); long start = System.currentTimeMillis(); String xml = plist.JSONCommand(command); Map<String, String> var = ImmutableMap.of("$WIRConnectionIdentifierKey", connectionId, "$bundleId", bundleId, "$WIRSenderKey", sender, "$WIRPageIdentifierKey", "" + pageId); for (String key : var.keySet()) { xml = xml.replace(key, var.get(key)); } sendMessage(xml); JSONObject response = handler.getResponse(command.getInt("id")); JSONObject error = response.optJSONObject("error"); if (error != null) { throw new RemoteExceptionException(error, command); } else if (response.optBoolean("wasThrown", false)) { throw new WebDriverException("remote JS exception " + response.toString(2)); } else { log.fine(System.currentTimeMillis() + "\t\t" + (System.currentTimeMillis() - start) + "ms\t" + command.getString("method") + " " + command); JSONObject res = response.getJSONObject("result"); if (res == null) { System.err.println("GOT a null result from " + response.toString(2)); } return res; } } catch (JSONException e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.wkrdp.internal.WebKitSyncronizer.java
License:Apache License
public void waitForSimToSendPages() { try {/*from w w w . j a v a 2s . com*/ simLock.lock(); if (driver.getPages() != null && driver.getPages().size() > 0) { return; } simSentPages.await(5, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new WebDriverException("InterruptedException before getting the pages."); } finally { simLock.unlock(); } }