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);
}
}
Aggregations