public Object executeScript(String script, Object... args) {
Object object = debugger.scriptExecutor(script, args);
// We probably have an element _or_ a list.
if (object instanceof ScriptResult) {
ScriptResult result = (ScriptResult) object;
Integer objectId = result.getObjectId();
if (objectId == null) {
return null;
} else if (result.getClassName().endsWith("Element")) {
return new OperaWebElement(this, objectId);
} else if (result.getClassName().equals("NodeList")) {
return processElements(objectId);
} else if (result.getClassName().equals("Array") || result.getClassName().equals("Object")) {
return debugger.examineScriptResult(objectId);
}
}
return object;