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:com.opera.core.systems.scope.stp.UmsEventParser.java

License:Apache License

private final GeneratedMessage.Builder<?> buildMessage(GeneratedMessage.Builder<?> builder, byte[] message) {
    try {/*from w  ww  . j  av a2s.  co  m*/
        return builder.mergeFrom(message);
    } catch (InvalidProtocolBufferException ex) {
        throw new WebDriverException(
                "Could not build " + builder.getDescriptorForType().getFullName() + " : " + ex.getMessage());
    }
}

From source file:com.opera.core.systems.ScopeServices.java

License:Apache License

/**
 * Gets information on available services and their versions from Opera.
 *///w  ww.j  a va 2s.  co m
private HostInfo getHostInfo() {
    Response response = executeCommand(ScopeCommand.HOST_INFO, null);

    try {
        return HostInfo.parseFrom(response.getPayload());
    } catch (InvalidProtocolBufferException ex) {
        throw new WebDriverException("Error while parsing host info");
    }
}

From source file:com.opera.core.systems.ScopeServices.java

License:Apache License

public void enableServices(List<String> requiredServices) {
    for (String requiredService : requiredServices) {
        try {/*from w w w.j av a 2  s .c o m*/
            if (getListedServices().contains(requiredService)) {
                enable(requiredService);
            }
        } catch (InvalidProtocolBufferException e) {
            throw new WebDriverException("Could not parse the message");
        }
    }
}

From source file:com.opera.core.systems.testing.InProject.java

License:Apache License

/**
 * Locates a file in the current project.
 *
 * @param path complete/full path to locate from the root of the project
 * @return file being sought, if it exists
 * @throws WebDriverException wrapped FileNotFoundException if file could not be found
 *///from   www.jav a 2 s . co m
public static File locate(String path) {
    File dir = new File(".").getAbsoluteFile();
    while (dir != null) {
        File needle = new File(dir, path);
        if (needle.exists()) {
            return needle;
        }
        dir = dir.getParentFile();
    }

    throw new WebDriverException(new FileNotFoundException("Could not find " + path + " in the project"));
}

From source file:com.opera.core.systems.WaitState.java

License:Apache License

private void internalWait(long timeout) throws WebDriverException {
    try {//from ww  w  .  j a  va  2  s  .c o m
        if (!connected) {
            throw new CommunicationException("Waiting aborted - not connected!");
        }
        lock.wait(timeout);
    } catch (InterruptedException e) {
        throw new WebDriverException(e);
    }
}

From source file:com.opera.core.systems.WaitState.java

License:Apache License

void onException(Exception e) {
    synchronized (lock) {
        events.add(new ResultItem(new WebDriverException(e)));
        connected = false;//from   w  w w  .  j  a va 2  s .c  o m
        lock.notify();
    }
}

From source file:com.qmetry.qaf.automation.ui.UiDriverFactory.java

License:Open Source License

private static WebDriver getDriverObj(Class<? extends WebDriver> of, Capabilities capabilities, String urlStr) {
    try {/*  w  ww. j  a va  2 s  . c  o  m*/
        Constructor<? extends WebDriver> constructor = of.getConstructor(Capabilities.class);
        return constructor.newInstance(capabilities);
    } catch (Exception e) {
        if (e.getCause() != null && e.getCause() instanceof WebDriverException) {
            throw (WebDriverException) e.getCause();
        }
        try {
            return of.newInstance();
        } catch (Exception e1) {
            try {

                Constructor<? extends WebDriver> constructor = of.getConstructor(URL.class, Capabilities.class);

                return constructor.newInstance(new URL(urlStr), capabilities);
            } catch (InvocationTargetException e2) {
                throw new WebDriverException(e2);
            } catch (InstantiationException e2) {
                throw new WebDriverException(e2);
            } catch (IllegalAccessException e2) {
                throw new WebDriverException(e2);
            } catch (IllegalArgumentException e2) {
                throw new WebDriverException(e2);
            } catch (MalformedURLException e2) {
                throw new WebDriverException(e2);
            } catch (NoSuchMethodException e2) {
                throw new WebDriverException(e2);
            } catch (SecurityException e2) {
                throw new WebDriverException(e2);
            }
        }
    }
}

From source file:com.qwazr.crawler.web.driver.BrowserDriver.java

License:Apache License

public Object executeScript(String javascript, boolean faultTolerant, Object... objects) {
    try {//from   w  ww  . j a v  a  2 s  . co  m
        if (!(driver instanceof JavascriptExecutor))
            throw new WebDriverException("The Web driver does not support javascript execution");
        JavascriptExecutor js = (JavascriptExecutor) driver;
        return js.executeScript(javascript, objects);
    } catch (WebDriverException e) {
        if (!faultTolerant)
            throw e;
        logger.warn(e.getMessage(), e);
        return null;
    }
}

From source file:com.qwazr.crawler.web.driver.BrowserDriver.java

License:Apache License

final public BufferedImage getScreenshot() throws IOException {
    if (!(driver instanceof TakesScreenshot))
        throw new WebDriverException("This browser driver does not support screenshot");
    TakesScreenshot takesScreenshot = (TakesScreenshot) driver;
    byte[] data = takesScreenshot.getScreenshotAs(OutputType.BYTES);
    return ImageIO.read(new ByteArrayInputStream(data));
}

From source file:com.qwazr.crawler.web.driver.BrowserDriver.java

License:Apache License

@Override
public Integer getStatusCode() {
    if (driver instanceof AdditionalCapabilities.ResponseHeader)
        return ((AdditionalCapabilities.ResponseHeader) driver).getStatusCode();
    throw new WebDriverException("GetStatusCode is not implemented in " + driver.getClass());
}