@Override protected void processTestElements(NSMutableArray<SeleniumTest.Element> elements) { int includeCount = 0; int i = 0; while (i < elements.count()) { SeleniumTest.Element element = elements.get(i); if (element instanceof SeleniumTest.MetaCommand) { SeleniumTest.MetaCommand metaCommand = (SeleniumTest.MetaCommand) element; if (metaCommand.getName().equals("include")) { if (includeCount >= INCLUDE_LIMIT) { throw new RuntimeException("Too many @include commands (recursive include?)"); } NSArray<SeleniumTest.Element> newElements = getIncludedArguments(metaCommand.argumentsString()); NSArray<SeleniumTest.Element> tailElements = elements.subarrayWithRange(new NSRange(i + 1, elements.count() - i - 1)); elements.removeObjectsInRange(new NSRange(i, elements.count() - i)); elements.addObjectsFromArray(newElements); elements.addObjectsFromArray(tailElements); ++includeCount; } } ++i; } }