@Override public WebDriver context(String name) { checkNotNull(name, "Must supply a context name"); try { execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", name)); return this; } catch (WebDriverException e) { throw new NoSuchContextException(e.getMessage(), e); } }
@Test public void verifyBasicScreenRecordingWorks() throws InterruptedException { try { driver.startRecordingScreen( new AndroidStartScreenRecordingOptions() .withTimeLimit(Duration.ofSeconds(5)) ); } catch (WebDriverException e) { if (e.getMessage().toLowerCase().contains("emulator")) { // screen recording only works on real devices return; } } Thread.sleep(5000); String result = driver.stopRecordingScreen(); assertThat(result, not(isEmptyString())); }
@Override public void run() { if (driver != null) { try { driver.quit(); } catch (WebDriverException mostLikelyLostContactWithTheBrowser) { LOGGER.debug("Failed to close a browser: {}", mostLikelyLostContactWithTheBrowser.getMessage()); } } } });
public void scrollToElement(By elementBy) { try { executeScript( "var x = $(arguments[0]);" + "window.scroll(0,parseInt(x.offset().top - 60));", webDriver.findElement(elementBy)); } catch (WebDriverException e) { if (e.getMessage().contains(NO_JQUERY_ERROR)) { logger.info(JS_ERROR, J_QUERY_IS_NOT_DEFINED, false); } } }
@Override public void click() { for(int i = 0; i < 5; i++){ try { logger.debug("click on element " + getDescription()); element.click(); break; } catch (WebDriverException e) { logger.debug("WebDriver Exception occured when clicking on the element "+element.getText() + " "+ e.getMessage()); } } }
/** * Handle WebDriver exception when this method is not implemented */ @Override public String getPageSource() { try { return super.getPageSource(); } catch (WebDriverException e) { logger.info("page source not get: " + e.getMessage()); return null; } }
public void appendStringToTitle(String webRtcMode) { try { browser.executeScript("appendStringToTitle('" + webRtcMode + "');"); } catch (WebDriverException we) { log.warn(we.getMessage()); } }
@Override public WebDriver context(String name) { checkNotNull(name, "Must supply a context name"); try { execute(DriverCommand.SWITCH_TO_CONTEXT, ImmutableMap.of("name", name)); return this; } catch (WebDriverException e) { throw new NoSuchContextException(e.getMessage(), e); } }
private void forcedQuit() { try { getDriverInstance().quit(); proxiedWebDriver = null; } catch (WebDriverException e) { LOGGER.warn("Closing a driver that was already closed: " + e.getMessage()); } }
private void forcedQuit() { try { getDriverInstance().quit(); proxiedWebDriver = null; } catch (WebDriverException e) { LOGGER.warn("Closing a driver that was already closed: " + e.getMessage()); } }
private boolean htmlunitScriptError(WebDriverException e) { if ((e.getCause() != null) && (e.getCause() instanceof ScriptException)) { LOGGER.warn("Ignoring HTMLUnit script error: " + e.getMessage()); return true; } else { return false; } }
private boolean htmlunitScriptError(WebDriverException e) { if ((e.getCause() != null) && (e.getCause() instanceof ScriptException)) { LOGGER.warn("Ignoring HTMLUnit script error: " + e.getMessage()); return true; } else { return false; } }
private void forcedQuit() { try { getDriverInstance().quit(); proxiedWebDriver = null; } catch (WebDriverException e) { LOGGER.warn("Closing a driver that was already closed: " + e.getMessage()); } }
public WebDriver newDriver(Capabilities capabilities) throws IOException { try { logger.debug("Creating new driver instance with capabilities: {}", capabilities); return new RemoteWebDriver(getDriverService().getUrl(), capabilities); } catch (WebDriverException couldNotReachDriverService) { logger.warn("Remote driver creation failed ({}), falling back on default driver creation", couldNotReachDriverService.getMessage().split("\n")[0]); return newDriverInstance(capabilities); } }
public void quit() { if (proxyInstanciated()) { try { getDriverInstance().quit(); } catch (WebDriverException e) { LOGGER.warn("Error while quitting the driver (" + e.getMessage() + ")"); } proxiedWebDriver = null; } }
public SerenityWebDriverException(WebDriverException testErrorException) { super(testErrorException.getCause()); this.detailedMessage = testErrorException.getMessage(); this.stackTrace = testErrorException.getStackTrace(); this.cause = testErrorException.getCause(); this.exceptionClass = testErrorException.getClass(); }
public void quit() { if (proxyInstanciated()) { try { getDriverInstance().quit(); } catch (WebDriverException e) { LOGGER.warn("Error while quitting the driver (" + e.getMessage() + ")"); } proxiedWebDriver = null; } }
public static void forDriver(WebDriver driver) { if (resolvedDriverFrom(driver) instanceof RemoteWebDriver) { try { ((RemoteWebDriver) resolvedDriverFrom(driver)).setFileDetector(new LocalFileDetector()); } catch(WebDriverException e) { if (!e.getMessage().contains("only works on remote webdriver instances obtained via RemoteWebDriver")) { throw e; } } } }
public void scrollToSpecificElement(WebElement element) { try { js.executeScript("arguments[0].scrollIntoView(true);", element); } catch (WebDriverException e) { if (e.getMessage().contains(XSSContent.NO_JQUERY_ERROR)) { Log.log("JSError", "JQuery is not defined", false); } } }
@Override public void redimension(WebDriver driver) { try { driver.manage().window().setSize(new Dimension(width, height)); driver.manage().window().setPosition(new Point(0, 0)); } catch (WebDriverException couldNotResizeScreen) { if (couldNotResizeScreen.getMessage().contains("Invalid requested size")) { driver.manage().window().maximize(); } } } }