Example usage for org.openqa.selenium WebDriverException getMessage

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

Introduction

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

Prototype

@Override
    public String getMessage() 

Source Link

Usage

From source file:dk.dma.ais.abnormal.web.IntegrationTestHelper.java

License:Open Source License

public static PhantomJSDriver createPhantomJSWebDriver() {
    PhantomJSDriver driver;// w w w . jav a2 s. c  om
    try {
        // DesiredCapabilities capabilities = new DesiredCapabilities();
        // PhantomJSDriverService driverService = PhantomJSDriverService.createDefaultService(capabilities);

        driver = new PhantomJSDriver(); //driverService, capabilities);
        driver.manage().window().setSize(new Dimension(1280, 1024));
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    } catch (WebDriverException e) {
        System.err.println("Message - " + e.getMessage());
        System.err.println("Additional info - " + e.getAdditionalInformation());
        System.err.println("Support url - " + e.getSupportUrl());
        System.err.println("System info - " + e.getSystemInformation());
        System.err.println("Build info - " + e.getBuildInformation());
        throw e;
    } catch (Throwable t) {
        System.err.println("Class - " + t.getClass());
        System.err.println("Message - " + t.getMessage());
        System.err.println("--------");
        t.printStackTrace(System.err);
        System.err.println("--------");
        throw t;
    }

    return driver;
}

From source file:endtoend.functions.jquery.forms.val.ValFunction_ContentEditableTest.java

License:Apache License

@Test
@FirefoxOnly/*from   w  w w  . ja v  a 2 s .c o m*/
public void val_write__divWithoutContentEditableAttribute___throws_exception__FIREFOX() {
    try {
        verifyAttemptToChangeValOfDivWithoutContentEditableHasNoEffect();
    } catch (org.openqa.selenium.WebDriverException e) {
        assertThat(e.getMessage(), startsWith(
                "Element <div id=\"div-without-contenteditable-but-with-text\"> is not reachable by keyboard"));
    }
}

From source file:endtoend.functions.jquery.forms.val.ValFunction_ContentEditableTest.java

License:Apache License

@Test
@ChromeOnly//from   w  ww  .ja  va 2  s.co m
public void val_write__divWithoutContentEditableAttribute___throws_exception__CHROME() {
    try {
        verifyAttemptToChangeValOfDivWithoutContentEditableHasNoEffect();
    } catch (org.openqa.selenium.WebDriverException e) {
        assertThat(e.getMessage(), startsWith("unknown error: cannot focus element"));
    }
}

From source file:galen.api.server.GalenCommandExecutor.java

License:Apache License

/**
 * Executes the command received over the Thrift interface inside an instance of RemoteWebDriver.
 * @param sessionId WebDriver SessionId.
 * @param commandName Command name./*www.j av  a2 s . c o  m*/
 * @param params Command params.
 * @return an instance of {@link org.openqa.selenium.remote.Response}
 * @throws TException
 */
@Override
public Response execute(String sessionId, String commandName, String params) throws TException {
    Map<String, Object> paramsAsMap = fromJsonToStringObjectMap(params);
    if (commandName.equals(DriverCommand.NEW_SESSION)) {
        try {
            log.info("Setting up new WebDriver session");
            HashMap<String, Object> hashMap = extractDesiredCapabilities(paramsAsMap);
            WebDriver driver = new RemoteWebDriver(new URL(remoteServerAddress),
                    new DesiredCapabilities(hashMap));
            DriversPool.get().set(driver);
            return createSessionInitSuccessResponse(driver);
        } catch (MalformedURLException e) {
            log.error("Provided URL is malformed " + remoteServerAddress);
            return createSessionInitFailureResponse("Provided URL is malformed " + remoteServerAddress);
        } catch (UnreachableBrowserException e) {
            log.error("Could not reach browser at URL " + remoteServerAddress
                    + " check remote server is running.");
            return createSessionInitFailureResponse("Could not reach browser at URL " + remoteServerAddress
                    + " check remote server is running.");
        } catch (WebDriverException e) {
            throw new RemoteWebDriverException(e.getMessage());
        }
    }
    Command driverCommand = new Command(new SessionId(sessionId), handleCommandNameExceptions(commandName),
            paramsAsMap);
    try {
        log.info(format("Executing command %s for sessionId %s", commandName, sessionId));
        WebDriver driver = DriversPool.get().getBySessionId(sessionId);
        org.openqa.selenium.remote.Response response = null;
        if (driver instanceof RemoteWebDriver) {
            response = ((RemoteWebDriver) driver).getCommandExecutor().execute(driverCommand);
        }
        if (response == null) {
            return null;
        } else {
            if (commandName.equals(DriverCommand.QUIT)) {
                DriversPool.get().removeDriverBySessionId(sessionId);
            }
            ThriftValueWrapper valueWrapper = new ThriftValueWrapper(response.getValue());
            return new Response(valueWrapper.getValue(), valueWrapper.getContainedValues(),
                    response.getSessionId(), response.getStatus(), response.getState());
        }
    } catch (IOException ioe) {
        log.error(format("IOException while executing command %s: %s", commandName, ioe.toString()));
    } catch (WebDriverException wex) {
        log.error(format("WebDriverException while executing command %s: + %s", commandName, wex.toString()));
        throw new RemoteWebDriverException(wex.getMessage());
    }
    return null;
}

From source file:io.appium.java_client.MobileErrorHandler.java

License:Apache License

public void throwIfMobileError(WebDriverException originalException) throws RuntimeException {

    Class<? extends WebDriverException> mobileErrorType = errorCodes
            .getExceptionType(originalException.getMessage());

    if (mobileErrorType == null) {
        throw originalException;
    }/*from   w w w .ja  v a 2s .  c om*/

    WebDriverException toThrow = null;

    if (toThrow == null) {
        toThrow = createThrowable(mobileErrorType, new Class<?>[] { String.class, Throwable.class },
                new Object[] { originalException.getMessage(), originalException.getCause() });
    }

    if (toThrow == null) {
        toThrow = createThrowable(mobileErrorType, new Class<?>[] { String.class },
                new Object[] { originalException.getMessage() });
    }

    if (toThrow == null) {
        toThrow = originalException;
    }

    throw toThrow;

}

From source file:io.github.seleniumquery.browser.driver.builders.OperaDriverBuilder.java

License:Apache License

private void throwCustomExceptionIfBinaryWasNotFound(WebDriverException e) {
    if (e.getMessage().contains("cannot find Opera binary")) {
        throw new SeleniumQueryException("The Opera browser BINARY was not found. Where is it?\n"
                + "Find out where it is and use .withBinary(<path-to-opera-binary>). Example:\n\n"
                + "$.driver().useOpera().withBinary(\"C:/Program Files/Opera/49.0.2725.47/opera.exe\").autoDriverDownload();\n\n\n"
                + "For more info, check the exception stack below.\n" + "\nOriginal error: " + e.getClass()
                + ": " + e.getMessage(), e);
    }/*from  w  ww  .  j  av a  2s . c o m*/
}

From source file:io.kahu.hawaii.cucumber.glue.html.HtmlSteps.java

License:Apache License

@After("@web")
public void afterScenario(Scenario scenario) {
    if (scenario.isFailed() && embedScreenshot) {
        try {/*  w  w  w .ja va 2 s. c o m*/
            byte[] screenshot = webDriver.getScreenshotAs(OutputType.BYTES);
            scenario.embed(screenshot, "image/png");
        } catch (WebDriverException somePlatformsDontSupportScreenshots) {
            System.err.println(somePlatformsDontSupportScreenshots.getMessage());
        }
    }
    webDriver.quit();
    webDriver = null;
}

From source file:io.selendroid.nativetests.NativeChildElementFindingTest.java

License:Apache License

@Test
public void shouldNotFindChildElementByCss() throws Exception {
    openStartActivity();//w  ww  . j a v a 2  s.c o m
    WebElement rootElement = driver().findElement(By.id("l10n"));
    try {
        rootElement.findElement(By.cssSelector("button[id='waitingButtonTest']"));
        Assert.fail("Finding Native elements by css selector is not supported.");
    } catch (WebDriverException e) {
        Assert.assertTrue(e.getMessage().contains("By locator ByCssSelector is curently not supported!"));
    }
}

From source file:io.selendroid.nativetests.NativeChildElementFindingTest.java

License:Apache License

@Test
public void shouldNotFindChildElementsByCss() throws Exception {
    openStartActivity();/*from   ww  w . ja v a  2s .c o m*/
    WebElement rootElement = driver().findElement(By.id("l10n"));
    try {
        rootElement.findElements(By.cssSelector("button[id='waitingButtonTest']"));
        Assert.fail("Finding Native elements by css selector is not supported.");
    } catch (WebDriverException e) {
        Assert.assertTrue(e.getMessage().contains("By locator ByCssSelector is curently not supported!"));
    }
}

From source file:io.selendroid.nativetests.NativeElementFindingTest.java

License:Apache License

@Test
public void shouldNotFindElementByCssSelector() throws Exception {
    openStartActivity();//  ww  w .  j a v  a  2s. c  om
    try {
        driver().findElement(By.cssSelector("button[id='linkId']"));
        Assert.fail("Finding Native elements by css selector is not supported.");
    } catch (WebDriverException e) {
        Assert.assertTrue(e.getMessage().contains("By locator ByCssSelector is curently not supported!"));
    }
}