diff --git a/RELEASENOTE.md b/RELEASENOTE.md index a97ebd3fc..38f1dc9ea 100644 --- a/RELEASENOTE.md +++ b/RELEASENOTE.md @@ -4,6 +4,7 @@ Selenese Runner Java Relase Note ### 3.29.0 * Don't take screenshots with assert* and `selectFrame` commands. (#315, #316) +* Add nested frame depth limit. (max depth is 16) (#311) * Update dependency versions. ### 3.28.0 diff --git a/src/main/java/jp/vmi/selenium/selenese/locator/WebDriverElementFinder.java b/src/main/java/jp/vmi/selenium/selenese/locator/WebDriverElementFinder.java index 59e613a61..b48b1ed62 100644 --- a/src/main/java/jp/vmi/selenium/selenese/locator/WebDriverElementFinder.java +++ b/src/main/java/jp/vmi/selenium/selenese/locator/WebDriverElementFinder.java @@ -37,6 +37,7 @@ public class WebDriverElementFinder { private static final int MIN_TIMEOUT = 3000; // ms private static final long RETRY_INTERVAL = 100; // ms + private static final int MAX_FRAME_DEPTH = 16; private static final Logger log = LoggerFactory.getLogger(WebDriverElementFinder.class); @@ -211,6 +212,10 @@ private List findElementsByLocator(LocatorHandler handler, WebDriver List result = handler.handle(driver, ploc.arg); if (!result.isEmpty()) return result; + if (ploc.frameIndexList.size() >= MAX_FRAME_DEPTH) { + log.warn("Nested (i)frame depth exceeded limit: " + MAX_FRAME_DEPTH); + return null; + } int iframeCount = driver.findElements(By.tagName("iframe")).size(); for (int index = 0; index < iframeCount; index++) { pushFrame(driver, ploc, index);