Search in sources :

Example 1 with NotFoundException

use of org.openqa.selenium.NotFoundException in project ats-framework by Axway.

the class HtmlNavigator method navigateToFrame.

@PublicAtsApi
public void navigateToFrame(WebDriver webDriver, UiElement element) {
    if (lastWebDriver != webDriver) {
        // this is a new WebDriver instance
        lastWebDriver = webDriver;
        lastFramesLocation = "";
    }
    String newFramesLocationProperty = element != null ? element.getElementProperty("frame") : null;
    try {
        if (newFramesLocationProperty == null) {
            // No frame selection. Go to top frame if not there yet
            if (!"".equals(lastFramesLocation)) {
                log.debug("Go to TOP frame");
                webDriver.switchTo().defaultContent();
                lastFramesLocation = "";
            }
        } else {
            lastFramesLocation = newFramesLocationProperty;
            log.debug("Go to frame: " + newFramesLocationProperty);
            String[] newFramesLocation = newFramesLocationProperty.split("\\->");
            webDriver.switchTo().defaultContent();
            for (String frame : newFramesLocation) {
                if (frame.startsWith("/") || frame.startsWith("(/")) {
                    WebElement frameElement = webDriver.findElement(By.xpath(frame.trim()));
                    webDriver.switchTo().frame(frameElement);
                } else {
                    webDriver.switchTo().frame(frame.trim());
                }
            }
        }
    } catch (NotFoundException nfe) {
        String msg = "Frame not found. Searched by: '" + (element != null ? element.getElementProperty("frame") : "") + "'";
        log.debug(msg);
        throw new ElementNotFoundException(msg, nfe);
    }
}
Also used : NotFoundException(org.openqa.selenium.NotFoundException) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) ElementNotFoundException(com.axway.ats.uiengine.exceptions.ElementNotFoundException) WebElement(org.openqa.selenium.WebElement) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

PublicAtsApi (com.axway.ats.common.PublicAtsApi)1 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)1 NotFoundException (org.openqa.selenium.NotFoundException)1 WebElement (org.openqa.selenium.WebElement)1