当前位置: 首页>>代码示例>>Java>>正文


Java NoSuchWindowException类代码示例

本文整理汇总了Java中org.openqa.selenium.NoSuchWindowException的典型用法代码示例。如果您正苦于以下问题:Java NoSuchWindowException类的具体用法?Java NoSuchWindowException怎么用?Java NoSuchWindowException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NoSuchWindowException类属于org.openqa.selenium包,在下文中一共展示了NoSuchWindowException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitForHandleNotPresent

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
/**
 * Wait for the window handle to disappear.
 * @throws Exception
 */
public void waitForHandleNotPresent() throws Exception {
	try {
		timed(getWaitTimeout(), getWaitInterval(), new Action<Boolean>() {
			@Override
			@Nullable
			public Boolean execute() throws Exception {
				if(!driver().getWindowHandles().contains(driver().getWindowHandle())) {
					return null;
				}
				return Boolean.FALSE;
			}
		});
	} catch(NoSuchWindowException e) {
		//Already gone, fine!
	}
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:21,代码来源:WebDriverConnector.java

示例2: closeAndQuitWebDriver

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
protected void closeAndQuitWebDriver() {
    if (driver != null) {
        if (WebDriverUtils.dontTearDownPropertyNotSet() && WebDriverUtils.dontTearDownOnFailure(isPassed())) {
            try {
                acceptAlertIfPresent();
                driver.close();
            } catch (NoSuchWindowException nswe) {
                System.out.println("NoSuchWindowException closing WebDriver " + nswe.getMessage());
            } finally {
                if (driver != null) {
                    driver.quit();
                }
            }
        }
    } else {
        System.out.println("WebDriver is null for " + this.getClass().toString() + " if using a remote hub did you include the port?");
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:19,代码来源:WebDriverAftBase.java

示例3: closeAndQuitWebDriver

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
private void closeAndQuitWebDriver() {
    if (driver != null) {
        if (WebDriverUtils.dontTearDownPropertyNotSet() && WebDriverUtils.dontTearDownOnFailure(passed)) {
            try {
                driver.close();
            } catch (NoSuchWindowException nswe) {
                System.out.println("NoSuchWindowException closing WebDriver " + nswe.getMessage());
            } finally {
                if (driver != null) {
                    driver.quit();
                }
            }
        }
    } else {
        System.out.println("WebDriver is null for " + this.getClass().toString());
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:JiraIssueCreation.java

示例4: closeAndQuitWebDriver

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
protected void closeAndQuitWebDriver() {
    if (driver != null) {
        if (WebDriverUtils.dontTearDownPropertyNotSet() && WebDriverUtils.dontTearDownOnFailure(passed)) {
            try {
                driver.close();
            } catch (NoSuchWindowException nswe) {
                System.out.println("NoSuchWindowException closing WebDriver " + nswe.getMessage());
            } finally {
                if (driver != null) {
                    driver.quit();
                }
            }
        }
    } else {
        System.out.println("WebDriver is null for " + this.getClass().toString());
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:18,代码来源:JenkinsJsonJobResultsBase.java

示例5: tearDown

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
/**
 * 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();
	}

}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:28,代码来源:CaseRunner.java

示例6: checkCloseWindowAlert

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
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);
	}
}
 
开发者ID:bigtester,项目名称:automation-test-engine,代码行数:24,代码来源:MultiWindowsHandler.java

示例7: shouldThrowFindableNotPresentExceptionIfDriverIsNotPresent

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void shouldThrowFindableNotPresentExceptionIfDriverIsNotPresent() throws IOException {
    TargetedWebDriver driver = mock(TargetedWebDriver.class);
    OutputStream outputStream = mock(OutputStream.class);
    Browser browser = new WebDriverBrowser(driver,
            new StubWebDriverParentContext(),
            new StubWebDriverElementContext());

    when(driver.getScreenshotAs(OutputType.BYTES))
            .thenThrow(NoSuchWindowException.class);
    try {
        browser.takeScreenshot(outputStream);
        fail("Expected FindableNotPresentException to be thrown");
    } catch (Exception e) {
        assertThat("Expected FindableNotPresentException to be thrown",
                e.getClass(), equalTo(FindableNotPresentException.class));
    }

    verify(outputStream).close();
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:22,代码来源:TakeScreenshotTest.java

示例8: selectMatching

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
protected static void selectMatching(WebDriver webDriver, Matcher matcher, String error) {
	String startingHandle = null;
	try {
		startingHandle = webDriver.getWindowHandle();
	} catch (NoSuchWindowException e) {
		// Window of current WebDriver instance is already closed
	}

	for (String handle : webDriver.getWindowHandles()) {
		webDriver.switchTo().window(handle);
		if (matcher.match(getCurrentWindowInfo(webDriver))) {
			return;
		}
	}

	if (startingHandle != null) {
		webDriver.switchTo().window(startingHandle);
	}
	throw new SeleniumLibraryNonFatalException(error);
}
 
开发者ID:Hi-Fi,项目名称:robotframework-seleniumlibrary-java,代码行数:21,代码来源:WindowManager.java

示例9: getWindowInfos

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
public static List<List<String>> getWindowInfos(WebDriver webDriver) {
	String startingHandle = null;
	try {
		startingHandle = webDriver.getWindowHandle();
	} catch (NoSuchWindowException e) {
		// Window of current WebDriver instance is already closed
	}

	List<List<String>> windowInfos = new ArrayList<List<String>>();
	try {
		for (String handle : webDriver.getWindowHandles()) {
			webDriver.switchTo().window(handle);
			windowInfos.add(getCurrentWindowInfo(webDriver));
		}
	} finally {
		if (startingHandle != null) {
			webDriver.switchTo().window(startingHandle);
		}
	}
	return windowInfos;
}
 
开发者ID:Hi-Fi,项目名称:robotframework-seleniumlibrary-java,代码行数:22,代码来源:WindowManager.java

示例10: selectMatching

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
protected static void selectMatching(WebDriver webDriver, Matcher matcher, String error) {
	String startingHandle = null;
	try {
		startingHandle = webDriver.getWindowHandle();
	} catch (NoSuchWindowException e) {
		// Window of current WebDriver instance is already closed
	}

	for (String handle : webDriver.getWindowHandles()) {
		webDriver.switchTo().window(handle);
		if (matcher.match(getCurrentWindowInfo(webDriver))) {
			return;
		}
	}

	if (startingHandle != null) {
		webDriver.switchTo().window(startingHandle);
	}
	throw new Selenium2LibraryNonFatalException(error);
}
 
开发者ID:MarkusBernhardt,项目名称:robotframework-selenium2library-java,代码行数:21,代码来源:WindowManager.java

示例11: windowThrowsExceptionWhenNotExisting

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
public void windowThrowsExceptionWhenNotExisting() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setVisible(true);
        }
    });
    try {
        driver.switchTo().window("My Dialog1");
        throw new MissingException(NoSuchWindowException.class);
    } catch (NoSuchWindowException e) {
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:JavaDriverTest.java

示例12: switchingToWindowByUnknownNameOrHandleThrowsException

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
@Test
void switchingToWindowByUnknownNameOrHandleThrowsException() {
    NoSuchWindowException exception = mock(NoSuchWindowException.class);
    when(webDriver.switchTo().window("fooBar")).thenThrow(exception);
    assertThrows(NoSuchWindowException.class, () -> {
        cut.onWindow("fooBar");
    });
    verify(events).fireExceptionEvent(exception);
    verifyNoMoreInteractions(events);
}
 
开发者ID:testIT-WebTester,项目名称:webtester2-core,代码行数:11,代码来源:FocusSetterTest.java

示例13: testExceptionHandlingInCaseAWindowIsNotFoundForTheGivenNameOrHandle

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
@Test(expected = NoSuchWindowException.class)
public void testExceptionHandlingInCaseAWindowIsNotFoundForTheGivenNameOrHandle() {

    TargetLocator locator = mockTargetLocator();
    NoSuchWindowException exception = createSeleniumExceptionOfClass(NoSuchWindowException.class);
    doThrow(exception).when(locator).window(NAME_OR_HANDLE);

    try {
        cut.setFocusOnWindow(NAME_OR_HANDLE);
    } finally {
        verifyLastEventFiredWasExceptionEventOf(exception);
    }

}
 
开发者ID:testIT-WebTester,项目名称:webtester-core,代码行数:15,代码来源:WebDriverBrowserTest.java

示例14: getCurrentTabIndex

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
public int getCurrentTabIndex(List<String> tabHandles) {
    try {
        String currentHandle = driver().getWindowHandle();
        return tabHandles.indexOf(currentHandle);
    } catch (NoSuchWindowException e) {
        return -1;
    }
}
 
开发者ID:fhoeben,项目名称:hsac-fitnesse-fixtures,代码行数:9,代码来源:SeleniumHelper.java

示例15: nth

import org.openqa.selenium.NoSuchWindowException; //导入依赖的package包/类
private WebDriver nth(final int zeroBasedIndex) {
    try {
        final List<String> windowHandles = webDriver.getWindowHandles().stream().collect(Collectors.toList());
        return webDriver.switchTo().window(windowHandles.get(zeroBasedIndex));
    } catch (IndexOutOfBoundsException e) {
        throw new NoSuchWindowException(e.getMessage(), e);
    }
}
 
开发者ID:MagenTys,项目名称:cinnamon,代码行数:9,代码来源:SwitchToWindowImpl.java


注:本文中的org.openqa.selenium.NoSuchWindowException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。