import java.util.Stack; //导入方法依赖的package包/类
private List getAllElementsInFrames(TeasyElement context, final By by, Stack currentFramesPath) {
List foundInCurrentFrame = newArrayList();
if (firstCallInContext.get()) {
avoidStaleness(context);
List elements = context.getWrappedWebElement().findElements(by);
if (!elements.isEmpty()) {
foundInCurrentFrame.addAll(elements);
}
}
if (!firstCallInContext.get()) {
foundInCurrentFrame.addAll(newArrayList(transform(driverFindElements(by), toFrameAwareWebElements)));
}
List currentFrames = getFramesForContext(context);
for (WebElement frame : currentFrames) {
if (!switchToFrame(frame)) {
continue;
}
currentFramesPath.push(frame);
//For resolve UnreachableBrowserException due to - java.net.SocketException: No buffer space available (maximum connections reached?): connect
//http://stackoverflow.com/questions/1226155/hunt-down-java-net-socketexception-no-buffer-space-available
TestUtils.waitForSomeTime(50, "Wait for resolve UnreachableBrowserException, due to - SocketException: No buffer space available");
foundInCurrentFrame.addAll(getAllElementsInFrames(context, by, currentFramesPath));
currentFramesPath.pop();
switchToDefaultContext();
currentFramesPath.forEach(this::switchToFrame);
}
return foundInCurrentFrame;
}