org.openqa.selenium.remote.UnreachableBrowserException Java Examples
The following examples show how to use
org.openqa.selenium.remote.UnreachableBrowserException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MobileElementState.java From ats-framework with Apache License 2.0 | 6 votes |
@PublicAtsApi public boolean isElementDisplayed() { try { WebElement webElement = MobileElementFinder.findElement(appiumDriver, element); if (webElement == null) { return false; } else { return webElement.isDisplayed(); } } catch (UnreachableBrowserException ube) { throw new MobileOperationException( "Check if there is connection to the target device and the Appium server is running", ube); } catch (Exception e) { // element is not present or got error checking if it is present return false; } }
Example #2
Source File: FirefoxDriverTest.java From selenium with Apache License 2.0 | 6 votes |
@Test public void shouldGetMeaningfulExceptionOnBrowserDeath() throws Exception { FirefoxDriver driver2 = new FirefoxDriver(); driver2.get(pages.formPage); // Grab the command executor CommandExecutor keptExecutor = driver2.getCommandExecutor(); SessionId sessionId = driver2.getSessionId(); try { Field field = RemoteWebDriver.class.getDeclaredField("executor"); field.setAccessible(true); CommandExecutor spoof = mock(CommandExecutor.class); doThrow(new IOException("The remote server died")) .when(spoof).execute(ArgumentMatchers.any()); field.set(driver2, spoof); driver2.get(pages.formPage); fail("Should have thrown."); } catch (UnreachableBrowserException e) { assertThat(e.getMessage()).contains("Error communicating with the remote browser"); } finally { keptExecutor.execute(new Command(sessionId, DriverCommand.QUIT)); } }
Example #3
Source File: SessionManager.java From JTAF-ExtWebDriver with Apache License 2.0 | 6 votes |
/** * Get the current session associated with this thread. Because a * SessionManager instance is thread-local, the notion of current is also * specific to a thread. * * * @param createIfNotFound * set to true if a session should be created if no session is * associated with the current sessionId * @return ExtWebDriver an ExtWebDriver instance * @see getCurrentSession() * @see getSession(String) * @see switchToSession(String) */ public ExtWebDriver getCurrentSession(boolean createIfNotFound) { for (int i = 0; i < MAX_RETRIES; i++) { ExtWebDriver sel = sessions.get(currentSessionId); try { if ((sel == null) && (createIfNotFound)) { sel = getNewSession(); } return sel; } catch (Exception e) { // if the exception is of type UnreachableBrowserException, try // again if (!(e instanceof UnreachableBrowserException)) { e.printStackTrace(); } } } return null; }
Example #4
Source File: PhantomJSDriverConfigTest.java From jmeter-plugins-webdriver with Apache License 2.0 | 5 votes |
@Before public void createConfig() throws IOException { config = new PhantomJSDriverConfig(); config.setPhantomJsExecutablePath(System.getProperty(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY)); JMeterVariables variables = new JMeterVariables(); JMeterContextService.getContext().setVariables(variables); try { config.threadStarted(); } catch (UnreachableBrowserException ignored) { // TODO: mock it properly } }
Example #5
Source File: MobileElementState.java From ats-framework with Apache License 2.0 | 5 votes |
@PublicAtsApi public boolean isElementPresent() { try { return MobileElementFinder.findElement(appiumDriver, element) != null; } catch (UnreachableBrowserException ube) { throw new MobileOperationException( "Check if there is connection to the target device and the Appium server is running", ube); } catch (Exception e) { // element is not present or got error checking if it is present return false; } }
Example #6
Source File: PageObject.java From seleniumtestsframework with Apache License 2.0 | 5 votes |
public final void close() throws NotCurrentPageException { if (WebUIDriver.getWebDriver() == null) { return; } SeleniumTestsPageListener.informPageUnload(this); TestLogging.log("close web page"); boolean isMultipleWindow = false; if (driver.getWindowHandles().size() > 1) { isMultipleWindow = true; } try { driver.close(); } catch (final WebDriverException ignore) { } if (WebUIDriver.getWebUIDriver().getMode().equalsIgnoreCase("LOCAL")) { try { Thread.sleep(1000 * 2); } catch (final InterruptedException e) { } } try { if (isMultipleWindow) { this.selectWindow(); } else { WebUIDriver.setWebDriver(null); } } catch (final UnreachableBrowserException ex) { WebUIDriver.setWebDriver(null); } }