Java 类org.openqa.selenium.remote.UnreachableBrowserException 实例源码
项目:googlecodejam-cli
文件:ApplicationCommand.java
/**
* Starts firefox through selenium to retrieve
* cookie instance and process initialization.
*
* @param driverSupplier Driver supplier to use.
* @param contest Contest identifier to use.
* @return <tt>true</tt> if the init command was correctly executed, <tt>false</tt> otherwise.
*/
private static CommandStatus browserInit(final Supplier<WebDriver> driverSupplier, final String contest) {
out.println("[Initialization] Web browser will open, please authenticate to your Google account with it.");
FirefoxDriverManager.getInstance().setup();
final SeleniumCookieSupplier supplier = new SeleniumCookieSupplier(Request.getHostname() + "/codejam", FirefoxDriver::new);
try {
final String cookie = supplier.get();
if (cookie == null) {
err.println("-> Retrieved cookie instance is null, abort.");
}
else {
return init(cookie, contest);
}
}
catch (final IOException | UnreachableBrowserException | GeneralSecurityException e) {
err.println("-> An error occurs while creating CodeJamSession");
if (Application.isVerbose()) {
e.printStackTrace();
}
}
return CommandStatus.FAILED;
}
项目:webcat-testing-platform
文件:NullPageObject.java
@Override
protected void takeScreenshotImpl(String methodName) {
try {
final byte[] screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
final IContext context = Context.getInstance();
context.addScreenshot(screenshot);
}
catch(UnreachableBrowserException ex) {
logger.log(Level.WARN, "Could not reach browser to take screenshot");
}
catch(WebDriverException webDriverEx) {
if(webDriverEx.getMessage().contains("Session not found")) {
logger.log(Level.WARN, "Could not reach browser to take screenshot");
} else {
throw webDriverEx;
}
}
}
项目:mineraloil-selenium
文件:Screenshot.java
public void takeScreenshot(String filename) {
filename = renameIfClassPath(filename);
screenShotDirectory = testClassDirectory.isEmpty() ? getDirectory("screenshots") : getDirectory("screenshots/" + testClassDirectory);
if (log.isDebugEnabled()) {
takeFullDesktopScreenshot(filename);
} else {
if (driver.isDriverStarted()) {
try {
filename += "_" + System.currentTimeMillis() + "_" + Thread.currentThread().getId() + ".png";
File scrFile = driver.takeScreenshot();
log.info("Creating Screenshot: " + screenShotDirectory + filename);
FileUtils.copyFile(scrFile, new File(screenShotDirectory + filename));
} catch (IOException | UnreachableBrowserException e) {
log.error(" Unable to take screenshot: " + e.toString());
}
} else {
log.error("Webdriver not started. Unable to take screenshot");
}
}
}
项目:automation-test-engine
文件:CaseRunner.java
/**
* Tear down.
*/
@AfterMethod(alwaysRun = true)
public void tearDown() {
try {
if (null != mainDriver) {
mainDriver.quit();
}
if (null != context) {
Map<String, IMyWebDriver> myWebDrivers = context
.getBeansOfType(IMyWebDriver.class);
for (IMyWebDriver myWebDriver2 : myWebDrivers.values()) {
WebDriver weD = myWebDriver2.getWebDriver();
if (null != weD)
weD.quit();
}
}
} catch (UnreachableBrowserException | NoSuchWindowException e) { // NOPMD
// browser has been closed, no action needs to be done here.
}
if (null != context) {
((ConfigurableApplicationContext) context).close();
}
}
项目:automation-test-engine
文件:MultiWindowsHandler.java
private void checkCloseWindowAlert(String winh)
throws NoAlertPresentException {
try {
Alert alt = getDriver().switchTo().alert();
if (alt == null)
throw GlobalUtils.createInternalError("web driver");
PopupPromptDialog aDialog = new PopupPromptDialog(getDriver(), alt,
alerts.size());
aDialog.setClosingWindowHandle(winh);
alerts.add(aDialog);
} catch (UnreachableBrowserException error) {
if (getNumberOfOpenWindows() > 0)
throw GlobalUtils
.createInternalError("ATE multi windows handler", error);
} catch (UnsupportedOperationException e) {
throw GlobalUtils
.createInternalError("Driver doesn't support alert handling yet", e);
} catch (NoSuchWindowException windClosedAlready) {
//do nothing if window closed without alert dialog intervention. for example in Chrome.
throw new NoAlertPresentException(windClosedAlready);
}
}
项目:JTAF-ExtWebDriver
文件:SessionManager.java
/**
* 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;
}
项目:teasy
文件:TeasyElementProvider.java
/**
* use {@link VisibleElementWaitFor#stale()}
*/
@Deprecated
protected final Boolean waitForStalenessOf(final WebElement webElement) {
try {
return elementFinder.waitForStalenessOf(webElement);
} catch (UnreachableBrowserException ignored) {
return true;
}
}
项目:teasy
文件:TeasyElementProvider.java
/**
* use {@link VisibleElementWaitFor#stale()}
*/
@Deprecated
protected final Boolean waitForStalenessOf(final WebElement webElement, long timeout) {
try {
return elementFinder.waitForStalenessOf(webElement, timeout);
} catch (UnreachableBrowserException ignored) {
return true;
}
}
项目:ats-framework
文件:MobileElementState.java
@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;
}
}
项目:ats-framework
文件:MobileElementState.java
@PublicAtsApi
public boolean isElementDisplayed() {
try {
return MobileElementFinder.findElement(appiumDriver, element).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;
}
}
项目:seleniumtestsframework
文件:PageObject.java
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);
}
}
项目:mineraloil-selenium
文件:Driver.java
public void get(String url) {
try {
getDriver().get(url);
} catch (UnreachableBrowserException e) {
// this is a workaround for losing the connection or failing to start driver
log.info("WebDriver died...attempting restart");
stopLastDriver();
startDriver();
getDriver().get(url);
}
}
项目:tm-examples
文件:SeleniumTests.java
public void getBaseURL() {
try {
driver.get(baseUrl);
} catch (UnreachableBrowserException e) {
System.out.println("driver.get() threw an exception.");
e.printStackTrace();
}
}
项目:android-webdriver-vm-demo
文件:TMTest.java
public void setDriver()
{
try
{
driver = new AndroidDriver();
}
catch(UnreachableBrowserException e)
{
System.out.println("Could not set driver...");
}
}
项目:android-webdriver-vm-demo
文件:TMTest.java
public void getBaseURL()
{
try
{
driver.get(baseUrl);
}
catch(UnreachableBrowserException e)
{
System.out.println("driver.get() threw an exception.");
e.printStackTrace();
}
}
项目:crawljax
文件:WebDriverFirefoxLinuxCrash.java
private void expectWebDriverExceptionWithConnectionExceptionCause() {
exception.expect(UnreachableBrowserException.class);
exception.expectCause(any(ConnectException.class));
}