List of usage examples for org.openqa.selenium WebDriverException WebDriverException
public WebDriverException(Throwable cause)
From source file:org.uiautomation.ios.wkrdp.internal.WebKitSyncronizer.java
License:Apache License
public void waitForSimToRegister() { try {//w w w .ja v a 2 s . c o m simLock.lock(); if (driver.getDevice() != null) { return; } simRegistered.await(5, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new WebDriverException("InterruptedException while waiting for the simulator to respond."); } finally { simLock.unlock(); } }
From source file:org.uiautomation.ios.wkrdp.internal.WebKitSyncronizer.java
License:Apache License
public void waitForSimToSendApps() { try {//w ww . j a v a 2 s .c om simLock.lock(); if (driver.getApplications() != null && !driver.getApplications().isEmpty()) { return; } simSentApps.await(5, TimeUnit.SECONDS); } catch (InterruptedException e) { throw new WebDriverException("InterruptedException while waiting for the simulator to send its apps."); } finally { simLock.unlock(); } }
From source file:org.uiautomation.ios.wkrdp.model.RemoteObject.java
License:Apache License
public <T> T call(String function) { JSONObject cmd = new JSONObject(); try {//from w w w. j a v a 2s . c o m cmd.put("method", "Runtime.callFunctionOn"); JSONArray args = new JSONArray(); args.put(new JSONObject().put("value", "")); cmd.put("params", new JSONObject().put("objectId", this.getId()) .put("functionDeclaration", "(function(arg) { var res = this" + function + "; return res;})") .put("arguments", args).put("returnByValue", false)); JSONObject response = inspector.sendCommand(cmd); return inspector.cast(response); } catch (JSONException e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.wkrdp.model.RemoteWebElement.java
License:Apache License
private void clickAtom() { try {/*from ww w . java 2s . co m*/ String f = "(function(arg) { " + "var text = " + IosAtoms.CLICK + "(arg);" + "return text;})"; JSONArray args = new JSONArray(); args.put(new JSONObject().put("objectId", getRemoteObject().getId())); JSONObject response = getInspectorResponse(f, args, true); inspector.cast(response); } catch (JSONException e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.wkrdp.model.RemoteWebElement.java
License:Apache License
private JSONObject getInspectorResponse(String javascript, JSONArray args, Boolean returnByValue) { JSONObject cmd = new JSONObject(); try {/* w w w .ja v a 2 s. c o m*/ cmd.put("method", "Runtime.callFunctionOn"); JSONObject params = new JSONObject().put("objectId", getRemoteObject().getId()) .put("functionDeclaration", javascript).put("returnByValue", returnByValue); if (args != null && args.length() > 0) { params.put("arguments", args); } cmd.put("params", params); JSONObject response = inspector.sendCommand(cmd); inspector.checkForJSErrors(response); return response; } catch (JSONException e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.wkrdp.model.RemoteWebNativeBackedElement.java
License:Apache License
public void nativeClick() { if ("option".equalsIgnoreCase(getTagName())) { click();//from ww w.j a va2s .co m } else { try { ((JavascriptExecutor) nativeDriver).executeScript(getNativeElementClickOnIt()); getInspector().checkForPageLoad(); } catch (Exception e) { throw new WebDriverException(e); } } }
From source file:org.uiautomation.ios.wkrdp.RemoteIOSWebDriver.java
License:Apache License
public void connect(String bundleId) { List<WebkitApplication> knownApps = getApplications(); for (WebkitApplication app : knownApps) { if (bundleId.equals(app.getBundleId())) { this.bundleId = bundleId; protocol.connect(bundleId);// www . j a v a 2 s .c om sync.waitForSimToSendPages(); switchTo(getPages().get(0)); if (getPages().size() > 1) { log.warning("Application started, but already have " + getPages().size() + " webviews. Connecting to the first one."); } return; } } throw new WebDriverException(bundleId + " not in the list " + knownApps + ".Either it's not started, or it has no webview to connect to."); }
From source file:org.uiautomation.ios.wkrdp.RemoteIOSWebDriver.java
License:Apache License
public void switchTo(String pageId) { for (WebkitPage p : getPages()) { if ((p.getPageId() + "").equals(pageId)) { switchTo(p);//from w w w . j ava2 s .com return; } } throw new WebDriverException("no such page " + pageId); }
From source file:org.uiautomation.ios.wkrdp.RemoteIOSWebDriver.java
License:Apache License
private BaseWebInspector connect(WebkitPage webkitPage) { for (WebkitPage page : getPages()) { if (page.equals(webkitPage)) { WebInspector inspector = new WebInspector(null, webkitPage.getPageId(), protocol, bundleId, connectionKey, session); protocol.attachToPage(page.getPageId()); inspector.sendCommand(Page.enablePageEvent()); inspector.sendCommand(Network.enable()); boolean ok = created.add(inspector); if (ok) { protocol.addListener(inspector); }//ww w .ja v a 2s . c om return inspector; } } throw new WebDriverException("Cannot connect to page " + webkitPage + ".Cannot find it."); }
From source file:org.uiautomation.ios.wkrdp.RemoteIOSWebDriver.java
License:Apache License
public int getWindowHandleIndex() { int pageId = currentInspector.getPageIdentifier(); for (WebkitPage p : getPages()) { if (p.getPageId() == pageId) { return getPages().indexOf(p); }/* w w w .j a v a 2 s . co m*/ } throw new WebDriverException("Cannot find current page."); }