Example usage for org.openqa.selenium WebDriverException WebDriverException

List of usage examples for org.openqa.selenium WebDriverException WebDriverException

Introduction

In this page you can find the example usage for org.openqa.selenium WebDriverException WebDriverException.

Prototype

public WebDriverException(Throwable cause) 

Source Link

Usage

From source file:org.uiautomation.ios.inspector.views.JSONView.java

License:Apache License

private String getContent() throws JSONException {
    if (object == null && array == null) {
        throw new WebDriverException("json view needs to have either jsonobject or array. Cannot be null");
    }/*  w  w w . ja  v  a2  s . c  o  m*/
    int indent = 2;
    return object != null ? object.toString(indent) : array.toString(indent);
}

From source file:org.uiautomation.ios.IOSCapabilities.java

License:Apache License

public void setSupportedDevices(List<DeviceType> devices) {
    if (devices.isEmpty()) {
        throw new WebDriverException("your app need to support at least 1  device.");
    }//from   ww w . j ava 2  s  .com
    setCapability(SUPPORTED_DEVICES, devices);
}

From source file:org.uiautomation.ios.IOSCapabilities.java

License:Apache License

public List<DeviceType> getSupportedDevicesFromDeviceFamily() {
    JSONArray o = (JSONArray) asMap().get(DEVICE_FAMILLY);
    List<DeviceType> devices = new ArrayList<DeviceType>();
    for (int i = 0; i < o.length(); i++) {
        try {//www  .j a v a 2  s.  co m
            devices.add(DeviceType.getFromFamilyCode(o.getInt(i)));
        } catch (JSONException e) {
            throw new WebDriverException(o.toString() + " but should contain only 1 or 2.");
        }
    }
    return devices;
}

From source file:org.uiautomation.ios.IOSCapabilities.java

License:Apache License

private List<String> getList(String key) {
    Object o = getCapability(key);
    if (o instanceof List<?>) {
        return (List<String>) o;
    } else if (o instanceof JSONArray) {
        JSONArray a = (JSONArray) o;/*from ww  w  .j  a  v  a  2 s  .  c  o m*/
        List<String> res = new ArrayList<String>();

        for (int i = 0; i < a.length(); i++) {
            try {
                res.add(a.getString(i));
            } catch (JSONException e) {
                throw new WebDriverException(e);
            }
        }
        return res;
    }
    throw new ClassCastException("expected collection of string, got " + o.getClass());
}

From source file:org.uiautomation.ios.mobileSafari.Atoms.java

License:Apache License

private static String load(String resource) throws IOException {
    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
    if (is == null) {
        throw new WebDriverException("cannot load : " + resource);
    }//w w w . j  ava2 s.c o m
    StringWriter writer = new StringWriter();
    IOUtils.copy(is, writer, "UTF-8");
    String content = writer.toString();
    return content;
}

From source file:org.uiautomation.ios.mobileSafari.PlistManager.java

License:Apache License

public static String loadFromTemplate(String templatePath) {
    if (SEND_JSON_COMMAND.equals(templatePath) && cacheTemplate != null) {
        return cacheTemplate;
    }/*from  ww w.  j av  a 2 s  .co  m*/

    InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(templatePath);
    if (is == null) {
        throw new WebDriverException("cannot load : " + templatePath);
    }
    StringWriter writer = new StringWriter();
    try {
        IOUtils.copy(is, writer, "UTF-8");
    } catch (IOException e) {
        throw new WebDriverException("Cannot load template " + templatePath);
    }
    String content = writer.toString();
    return content;
}

From source file:org.uiautomation.ios.mobileSafari.PlistManager.java

License:Apache License

public byte[] plistXmlToBinary(String msg) {
    NSObject object = null;//www  .  j a  v  a  2s. c  om
    try {
        object = XMLPropertyListParser.parse(msg.getBytes());
        return BinaryPropertyListWriter.writeToArray(object);
    } catch (Exception e) {
        throw new WebDriverException(e);
    }

}

From source file:org.uiautomation.ios.mobileSafari.remoteWebkitProtocol.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 a va2 s.  c  om
        }
    }
    throw new WebDriverException("no such page " + pageId);
}

From source file:org.uiautomation.ios.mobileSafari.remoteWebkitProtocol.SimulatorSession.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;
            simulatorProtocol.sendConnectToApplication(connectionKey, bundleId);
            waitForSimToSendPages();//from   ww  w  . j  a  va 2 s  .  co m
            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.mobileSafari.remoteWebkitProtocol.SimulatorSession.java

License:Apache License

private void waitForSimToSendPages() {
    try {/*ww w. j ava 2s  . com*/
        simLock.lock();
        if (pages != null && pages.size() > 0) {
            return;
        }
        simSentPages.await(5, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        throw new WebDriverException("InterruptedException before getting the pages.");
    } finally {
        simLock.unlock();
    }
}