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(String message, Throwable cause) 

Source Link

Usage

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

License:Apache License

public FileTo64EncodedStringUtils(File source) {
    this.source = source;
    try {//w  w  w  .java2  s .c  o  m
        waitForFileToAppearOnDisk();
    } catch (InterruptedException e) {
        throw new WebDriverException("Interrupted waiting for the screenshot to be written on disk.", e);
    }
}

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

License:Apache License

public File getScript(int port, String aut, String opaqueKey) {
    try {/*from w w w .j a  v a 2 s  .  co m*/
        String content = generateScriptContent(port, aut, opaqueKey);
        return createTmpScript(content);
    } catch (Exception e) {
        throw new WebDriverException("cannot generate the script for instrument.", e);
    }
}

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

License:Apache License

/**
 * set the emulator to the given locale.Required a clean context (can only be done after "reset
 * content and settings" )//from ww w  .ja  v a2s  .  c  o m
 *
 * @param locale   fr_FR
 * @param language fr
 */
public void setL10N(String locale, String language) {
    try {
        JSONObject plistJSON = getPreferenceFile(locale, language);
        writeOnDisk(plistJSON, globalPreferencePlist);
    } catch (Exception e) {
        throw new WebDriverException("cannot configure simulator", e);
    }
}

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

License:Apache License

/**
 * @param maxWaitMillis max time to wait for the command to finish, -1 for not limit
 */// ww  w. j a  v  a 2 s.co m
public int waitFor(int maxWaitMillis) {
    Timer forceStopTimer = null;
    try {
        if (maxWaitMillis > 0) {
            forceStopTimer = new Timer(true);
            forceStopTimer.schedule(new TimerTask() {
                @Override
                public void run() {
                    process.destroy();
                }
            }, maxWaitMillis);
        }
        return process.waitFor();
    } catch (InterruptedException e) {
        throw new WebDriverException("error waiting for " + args + " to finish.", e);
    } finally {
        if (forceStopTimer != null)
            forceStopTimer.cancel();
    }
}

From source file:org.uiautomation.ios.utils.InstrumentsGeneratedImage.java

License:Apache License

public InstrumentsGeneratedImage(File source, Orientation orientation) {
    this.source = source;
    this.orientation = orientation;
    try {// ww  w  . j a v a  2  s  .c o m
        waitForFileToAppearOnDisk();
        image = rotate();
    } catch (InterruptedException e) {
        throw new WebDriverException("Interrupted waiting for the screenshot to be written on disk.", e);
    } finally {
        source.delete();
    }
}

From source file:org.uiautomation.ios.utils.PlistFileUtils.java

License:Apache License

private Map<String, Object> read(File plist) {
    try {// w w w  .j  a  v a2 s.  c  o  m
        NSObject object = PropertyListParser.parse(plist);
        ApplicationInfo info = new ApplicationInfo(object);
        return info.getProperties();
    } catch (Exception ex) {
        throw new WebDriverException("Cannot parse " + plist.getAbsolutePath() + ": " + ex.getMessage(), ex);
    }
}

From source file:org.uiautomation.ios.wkrdp.command.Runtime.java

License:Apache License

public static JSONObject evaluate(String js) {
    try {//from w  ww  .  j av  a 2  s .co  m
        JSONObject cmd = new JSONObject();
        cmd.put("method", "Runtime.evaluate").put("params",
                new JSONObject().put("expression", js).put("objectGroup", "console")
                        .put("includeCommandLineAPI", true).put("doNotPauseOnExceptionsAndMuteConsole", true)
                        .put("returnByValue", false));

        return cmd;
    } catch (JSONException e) {
        throw new WebDriverException("json encoding", e);
    }

}

From source file:org.uiautomation.ios.wkrdp.internal.SimulatorProtocolImpl.java

License:Apache License

public void start() {
    try {/*w w w .jav  a  2 s  .  co  m*/
        if (socket != null && (socket.isConnected() || !socket.isClosed())) {
            socket.close();
        }
        socket = new Socket(LOCALHOST_IPV6, port);
    } catch (IOException e) {
        throw new WebDriverException(
                "Cannot connect to the simulator socket on port 27753. Check that you don't have a firewall blocking it.",
                e);
    }
    startListenerThread();
    //sendCommand(PlistManager.SET_CONNECTION_KEY);
    //sendCommand(PlistManager.CONNECT_TO_APP);
    //sendCommand(PlistManager.SET_SENDER_KEY);
}

From source file:org.xwiki.index.test.po.DocumentPicker.java

License:Open Source License

/**
 * Wait for the Breadcrumb to display the passed path string and throw an exception if the timeout is reached. Note
 * that we need to wait since the Breadcrumb is udated live and asserting its content without waiting would lead to
 * false positives.//  w w w  . j  a v a  2s .co  m
 * <p/>
 * Note: This method can not be implemented inside {@link BreadcrumbElement} because a change of parent replaces
 * completely the {@link BreadcrumbElement}'s container and thus it becomes stale. To avoid that, at each wait
 * iteration, we lookup the current breadcrumb element and not a cached one.
 *
 * @param expectedPathString the path string to wait for
 * @since 7.2RC1
 */
public void waitForLocation(final String expectedPathString) {
    // TODO: Ugly hack. Would need to find a better solution
    final StringBuilder currentValue = new StringBuilder();

    try {
        getDriver().waitUntilCondition(new ExpectedCondition<Boolean>() {
            @Override
            public Boolean apply(WebDriver driver) {
                try {
                    String value = getLocation().getPathAsString();

                    currentValue.setLength(0);
                    currentValue.append(value);

                    return expectedPathString.equals(value);
                } catch (Exception e) {
                    return false;
                }
            }
        });
    } catch (WebDriverException e) {
        // Display a nicer error message than would be displayed otherwise
        throw new WebDriverException(
                String.format("Found [%s], was expecting [%s]", currentValue.toString(), expectedPathString),
                e);
    }
}

From source file:org.xwiki.index.test.po.DocumentPicker.java

License:Open Source License

/**
 * Wait for the Breadcrumb to display the passed path and throw an exception if the timeout is reached. Note that we
 * need to wait since the Breadcrumb is udated live and asserting its content without waiting would lead to false
 * positives.// ww w  .ja va 2  s. com
 * <p/>
 * Note: This method can not be implemented inside {@link BreadcrumbElement} because a change of parent replaces
 * completely the {@link BreadcrumbElement}'s container and thus it becomes stale. To avoid that, at each wait
 * iteration, we lookup the current breadcrumb element and not a cached one.
 *
 * @param expectedPath the path to wait for
 * @since 7.2RC1
 */
public void waitForLocation(final List<String> expectedPath) {
    // TODO: Ugly hack. Would need to find a better solution
    final List<String> currentPath = new ArrayList<String>();

    try {
        getDriver().waitUntilCondition(new ExpectedCondition<Boolean>() {
            @Override
            public Boolean apply(WebDriver driver) {
                try {
                    List<String> path = getLocation().getPath();

                    currentPath.clear();
                    currentPath.addAll(path);

                    return expectedPath.equals(path);
                } catch (Exception e) {
                    return false;
                }
            }
        });
    } catch (WebDriverException e) {
        // Display a nicer error message than would be displayed otherwise
        throw new WebDriverException(String.format("Found %s, was expecting %s", currentPath, expectedPath), e);
    }
}