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.server.simulator.IOSSimulatorManager.java

License:Apache License

private String validateSDK(String sdk) {
    if (!sdks.contains(sdk)) {
        throw new WebDriverException("desired sdk " + sdk + " isn't installed. Installed :" + sdks);
    }/* w  w w .j a  va 2 s . c o  m*/
    return sdk;
}

From source file:org.uiautomation.ios.server.utils.ClassicCommands.java

License:Apache License

public static File getXCodeInstall() {
    List<String> cmd = new ArrayList<String>();
    cmd.add("/usr/bin/xcrun");
    cmd.add("-find");
    cmd.add("xcodebuild");

    Command c = new Command(cmd, false);
    c.executeAndWait();/* w w  w  . j a v  a 2 s . co  m*/

    if (c.getStdOut().size() != 1) {
        throw new WebDriverException("cannot find XCode location." + c.getStdOut());
    }

    String path = c.getStdOut().get(0);

    String pattern = ".app/";
    int index = path.indexOf(pattern);
    String res = path.substring(0, index + pattern.length());
    return new File(res);

}

From source file:org.uiautomation.ios.server.utils.ClassicCommands.java

License:Apache License

public static File getAutomationTemplate() {
    List<String> cmd = new ArrayList<String>();
    cmd.add("instruments");
    cmd.add("-s");
    Command c = new Command(cmd, false);

    Grep grep = new Grep("Automation.tracetemplate");
    c.registerListener(grep);//from w  w  w .j a  v a2 s. co  m
    c.executeAndWait();
    List<String> res = grep.getMatching();
    if (res.size() == 0) {
        throw new WebDriverException("expected 1 result for automation on instruments -s , got " + res);
    }
    String path = res.get(0);
    path = path.replaceFirst(",", "");
    path = path.replaceAll("\"", "");
    path = path.trim();
    File f = new File(path);
    if (!f.exists()) {
        throw new WebDriverException(f + "isn't a valid template.");
    }
    return f;
}

From source file:org.uiautomation.ios.server.utils.ClassicCommands.java

License:Apache License

public List<String> getSDKs() {
    if (!ok) {//  w ww . j  a v a  2s. co m
        throw new WebDriverException("there was an error.stderr is not empty");
    }
    return sdks;
}

From source file:org.uiautomation.ios.server.utils.Command.java

License:Apache License

/**
 * execute the command, and wait for it to finish. Also wait for stdout and
 * std err listener to finish processing their streams.
 * // w  ww  .  j  a  v a  2 s  .  c o  m
 * @throws IOSAutomationSetupException
 */
public void executeAndWait() {
    start();
    int exitCode = waitFor();
    if (exitCode != 0) {
        throw new WebDriverException("execution failed. Exit code =" + exitCode + " , command was : " + args);
    }
    for (Thread t : threads) {
        try {
            t.join();
        } catch (InterruptedException e) {
            throw new WebDriverException(e);
        }
    }

}

From source file:org.uiautomation.ios.server.utils.FileTo64EncodedStringUtils.java

License:Apache License

private void waitForFileToAppearOnDisk() throws InterruptedException {

    int cpt = 0;//from   w  w w.j a  v  a2 s.c o  m
    while (!source.exists()) {
        Thread.sleep(250);
        cpt++;
        if (cpt > 5 * 4) {
            throw new WebDriverException("timeout waiting for screenshot file to be written.");
        }
    }
    return;
}

From source file:org.uiautomation.ios.server.utils.hack.TimeSpeeder.java

License:Apache License

private void speedTime() throws Exception {
    log.info("Speeding time");
    long time = System.currentTimeMillis();
    int i = 0;/* w ww  .  ja v a2s .  com*/
    int delta = 1000;
    while (isActive()) {
        i++;
        Thread.sleep(50);
        long newTime = time + (i * delta);
        Date d = new Date(newTime);
        List<String> c = new ArrayList<String>();
        c.add("sudo");
        c.add("/bin/date");
        // TODO freynaud
        c.add(get(d.getHours()) + get(d.getMinutes()) + "." + get(d.getSeconds()));
        ProcessBuilder builder = new ProcessBuilder(c);
        Process p = builder.start();
        int exit = p.waitFor();
        if (exit != 0) {
            throw new WebDriverException("couldn't set time" + c);
        }
    }
}

From source file:org.uiautomation.ios.server.utils.ScriptHelper.java

License:Apache License

private 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  .  ja  v a2 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.server.utils.ScriptHelper.java

License:Apache License

public File createTmpScript(String content) {
    try {/*  w  w w . ja  v a2 s .c  om*/
        File res = File.createTempFile(FILE_NAME, ".js");
        Writer writer = new FileWriter(res);
        IOUtils.copy(IOUtils.toInputStream(content), writer, "UTF-8");
        IOUtils.closeQuietly(writer);
        return res;
    } catch (Exception e) {
        throw new WebDriverException("Cannot generate script.");
    }

}

From source file:org.uiautomation.ios.server.utils.SimulatorSettings.java

License:Apache License

public void setLocationPreference(boolean authorized, String bundleId) {
    File f = new File(contentAndSettingsFolder + "/Library/Caches/locationd/", "clients.plist");

    try {//from   w ww  .j  a  va 2  s.c o m
        JSONObject clients = new JSONObject();
        JSONObject options = new JSONObject();
        options.put("Whitelisted", false);
        options.put("BundleId", bundleId);
        options.put("Authorized", authorized);
        clients.put(bundleId, options);
        writeOnDisk(clients, f);
    } catch (Exception e) {
        throw new WebDriverException("cannot set location in " + f.getAbsolutePath());
    }
}