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


Java NoSuchFrameException类代码示例

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


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

示例1: switchingToFrameByUnknownIndexThrowsException

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

示例2: switchToFrame

import org.openqa.selenium.NoSuchFrameException; //导入依赖的package包/类
private void switchToFrame(String frameIdentification) throws NoSuchFrameException {
	LOGGER.debug("frame identification: " + frameIdentification);

	if (frameIdentification.contains(".")) {
		String[] frames = frameIdentification.split("\\.");

		for (String frameId : frames) {
			LOGGER.debug("switching to frame: " + frameId);
			browser.switchTo().frame(frameId);
		}

	} else {
		browser.switchTo().frame(frameIdentification);
	}

}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:17,代码来源:WebDriverBackedEmbeddedBrowser.java

示例3: getContentDocument

import org.openqa.selenium.NoSuchFrameException; //导入依赖的package包/类
public RemoteWebElement getContentDocument() throws Exception {
  JsonObject response =
      getInspectorResponse(
          "(function(arg) { var document = this.contentDocument; return document;})", false);
  RemoteObject ro = inspector.cast(response);
  if (ro == null) {
    throw new NoSuchFrameException("Cannot find the document associated with the frame.");
  } else {
    return ro.getWebElement();
  }
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:12,代码来源:RemoteWebElement.java

示例4: getContentWindow

import org.openqa.selenium.NoSuchFrameException; //导入依赖的package包/类
public RemoteWebElement getContentWindow() throws Exception {
  JsonObject response =
      getInspectorResponse(
          "(function(arg) { var window = this.contentWindow; return window;})", false);
  RemoteObject ro = inspector.cast(response);
  if (ro == null) {
    throw new NoSuchFrameException("Cannot find the window associated with the frame.");
  } else {
    return ro.getWebElement();
  }
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:12,代码来源:RemoteWebElement.java

示例5: getIframe

import org.openqa.selenium.NoSuchFrameException; //导入依赖的package包/类
private RemoteWebElement getIframe(Integer index) throws Exception {
  List<RemoteWebElement> iframes = getWebDriver().findElementsByCssSelector(
      "iframe,frame");
  try {
    return iframes.get(index);
  } catch (IndexOutOfBoundsException i) {
    throw new NoSuchFrameException(
        "detected " + iframes.size() + " frames. Cannot get index = " + index);
  }
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:11,代码来源:SetFrameHandler.java

示例6: switchingToFrameByUnknownNameOrIdThrowsException

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

示例7: switchingToFrameByNonFrameFragmentThrowsException

import org.openqa.selenium.NoSuchFrameException; //导入依赖的package包/类
@Test
void switchingToFrameByNonFrameFragmentThrowsException() {
    PageFragment fragment = MockFactory.fragment().withName("The Name").build();
    NoSuchFrameException exception = mock(NoSuchFrameException.class);
    when(webDriver.switchTo().frame(fragment.webElement())).thenThrow(exception);
    assertThrows(NoSuchFrameException.class, () -> {
        cut.onFrame(fragment);
    });
    verify(events).fireExceptionEvent(exception);
    verifyNoMoreInteractions(events);
}
 
开发者ID:testIT-WebTester,项目名称:webtester2-core,代码行数:12,代码来源:FocusSetterTest.java

示例8: getWait

import org.openqa.selenium.NoSuchFrameException; //导入依赖的package包/类
private WebDriverWait getWait(int timeOutInSeconds,int pollingEveryInMiliSec) {
	oLog.debug("");
	WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
	wait.pollingEvery(pollingEveryInMiliSec, TimeUnit.MILLISECONDS);
	wait.ignoring(NoSuchElementException.class);
	wait.ignoring(ElementNotVisibleException.class);
	wait.ignoring(StaleElementReferenceException.class);
	wait.ignoring(NoSuchFrameException.class);
	return wait;
}
 
开发者ID:rahulrathore44,项目名称:SeleniumCucumber,代码行数:11,代码来源:WaitHelper.java

示例9: testExceptionHandlingInCaseAFrameIsNotFoundForTheGivenIndex

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

    TargetLocator locator = mockTargetLocator();
    NoSuchFrameException exception = createSeleniumExceptionOfClass(NoSuchFrameException.class);
    doThrow(exception).when(locator).frame(INDEX);

    try {
        cut.setFocusOnFrame(INDEX);
    } finally {
        verifyLastEventFiredWasExceptionEventOf(exception);
    }

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

示例10: testExceptionHandlingInCaseAFrameIsNotFoundForTheGivenNameOrId

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

    TargetLocator locator = mockTargetLocator();
    NoSuchFrameException exception = createSeleniumExceptionOfClass(NoSuchFrameException.class);
    doThrow(exception).when(locator).frame(NAME_OR_ID);

    try {
        cut.setFocusOnFrame(NAME_OR_ID);
    } finally {
        verifyLastEventFiredWasExceptionEventOf(exception);
    }

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

示例11: locateFrameAndgetSource

import org.openqa.selenium.NoSuchFrameException; //导入依赖的package包/类
private void locateFrameAndgetSource(Document document, String topFrame, Element frameElement) throws NoSuchFrameException {
	String frameIdentification = "";

	if (topFrame != null && !topFrame.equals("")) {
		frameIdentification += topFrame + ".";
	}

	String nameId = DomUtils.getFrameIdentification(frameElement);

	if (nameId != null
	        && !ignoreFrameChecker.isFrameIgnored(frameIdentification + nameId)) {
		frameIdentification += nameId;

		String handle = browser.getWindowHandle();

		LOGGER.debug("The current H: " + handle);

		switchToFrame(frameIdentification);

		String toAppend = browser.getPageSource();

		LOGGER.debug("frame dom: " + toAppend);

		browser.switchTo().defaultContent();

		try {
			Element toAppendElement = DomUtils.asDocument(toAppend).getDocumentElement();
			Element importedElement =
			        (Element) document.importNode(toAppendElement, true);
			frameElement.appendChild(importedElement);

			appendFrameContent(importedElement, document, frameIdentification);
		} catch (DOMException | IOException e) {
			LOGGER.info("Got exception while inspecting a frame:" + frameIdentification
			        + " continuing...", e);
		}
	}
}
 
开发者ID:aminmf,项目名称:crawljax,代码行数:39,代码来源:WebDriverBackedEmbeddedBrowser.java

示例12: attempt

import org.openqa.selenium.NoSuchFrameException; //导入依赖的package包/类
/**
 * Wrapper for interacting with a targeted driver that may or may not actually be present.
 */
private void attempt(Runnable action) {
    try {
        action.run();
    } catch (NoSuchFrameException | NoSuchWindowException | NoSuchSessionException e) {
        throw new FindableNotPresentException(this, e);
    }
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:11,代码来源:WebDriverBrowser.java

示例13: attemptAndGet

import org.openqa.selenium.NoSuchFrameException; //导入依赖的package包/类
/**
 * Wrapper for interacting with a targeted driver that may or may not actually be present.
 * Returns a result.
 */
private <T> T attemptAndGet(Supplier<T> action) {
    try {
        return action.get();
    } catch (NoSuchFrameException | NoSuchWindowException | NoSuchSessionException e) {
        throw new FindableNotPresentException(this, e);
    }
}
 
开发者ID:darcy-framework,项目名称:darcy-webdriver,代码行数:12,代码来源:WebDriverBrowser.java

示例14: selectFrameSafe

import org.openqa.selenium.NoSuchFrameException; //导入依赖的package包/类
protected static void selectFrameSafe(WebDriver driver, String locator) {
    try {
        driver.switchTo().frame(locator);
    } catch (NoSuchFrameException nsfe) {
        // don't fail
    }
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:8,代码来源:WebDriverUtil.java

示例15: serveRequest

import org.openqa.selenium.NoSuchFrameException; //导入依赖的package包/类
/**
 * Serves the given request of the given client.
 * 
 * @param request
 *            The request to serve
 * @param clientSocket
 *            The client to serve
 * @throws IOException
 *             If an I/O-Exception occurs
 * @throws WindowHandleNotFoundException
 *             If a window handle could not be found
 */
private void serveRequest(final String request, final Socket clientSocket) throws IOException {
	try {
		// Reject the request if empty
		if (request == null || request.trim().length() <= 0) {
			HttpUtil.sendError(EHttpStatus.BAD_REQUEST, clientSocket);
			return;
		}

		// Reject the request if not a GET request
		final Pattern requestPattern = Pattern.compile(GET_REQUEST_PATTERN);
		final Matcher requestMatcher = requestPattern.matcher(request);
		if (!requestMatcher.matches()) {
			HttpUtil.sendError(EHttpStatus.BAD_REQUEST, clientSocket);
			return;
		}

		// Strip the content of the GET request
		final String requestContent = requestMatcher.group(1);

		// Serve create requests
		final boolean isCreateRequest = requestContent.startsWith(CREATE_REQUEST);
		if (isCreateRequest) {
			serveCreateRequest(clientSocket);
			return;
		}

		// Serve post message requests
		final boolean isPostMessageRequest = requestContent.startsWith(POST_MESSAGE_REQUEST);
		if (isPostMessageRequest) {
			servePostMessageRequest(requestContent, clientSocket);
			return;
		}

		// Serve get message requests
		final boolean isGetMessageRequest = requestContent.startsWith(GET_MESSAGE_REQUEST);
		if (isGetMessageRequest) {
			serveGetMessageRequest(requestContent, clientSocket);
			return;
		}

		// Serve shutdown requests
		final boolean isShutdownRequest = requestContent.startsWith(SHUTDOWN_REQUEST);
		if (isShutdownRequest) {
			serveShutdownRequest(requestContent, clientSocket);
			return;
		}

		// Request type not supported
		HttpUtil.sendError(EHttpStatus.NOT_IMPLEMENTED, clientSocket);
	} catch (final WindowHandleNotFoundException | StaleElementReferenceException | TimeoutException
			| NoSuchElementException | NoSuchFrameException | UnexpectedUnsupportedEncodingException e) {
		// Log the error and reject the request
		this.mLogger.logError("Server error while serving request: " + LoggerUtil.getStackTrace(e));
		HttpUtil.sendError(EHttpStatus.INTERNAL_SERVER_ERROR, clientSocket);
	}
}
 
开发者ID:ZabuzaW,项目名称:BrainBridge,代码行数:69,代码来源:Service.java


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