private String getCommandOutput(ExtendedSeleniumCommand command, String[] values) { try { if (command.returnTypeIsArray()) { return executeArrayCommand(command.getSeleniumCommand(), values); } else { return executeCommand(command.getSeleniumCommand(), values); } } catch (final SeleniumException e) { String output = "Execution of command failed: " + e.getMessage(); LOG.error(output); if (!(command.isAssertCommand() || command.isVerifyCommand() || command.isWaitForCommand())) { throw e; } return output; } }
private boolean executeDoCommand(final String methodName, final String[] values) { final ExtendedSeleniumCommand command = new ExtendedSeleniumCommand(methodName); String output = null; boolean result = true; if (!locatorCheck.verifyElementPresent(command, values)) { result = false; } else if (command.requiresPolling()) { long timeoutTime = System.currentTimeMillis() + timeout; do { output = executeCommand(command, values, 0); result = checkResult(command, values[values.length - 1], output); if (!result) { delayIfNeeded(pollDelay); } } while (!result && timeoutTime > System.currentTimeMillis()); LOG.info( "WaitFor- command '" + command.getSeleniumCommand() + (result ? "' succeeded" : "' failed")); } else { output = executeCommand(command, values, stepDelay); if (command.isCaptureEntirePageScreenshotCommand()) { writeToFile(values[0], output); result = true; } else if (command.isAssertCommand() || command.isVerifyCommand() || command.isWaitForCommand()) { String expected = values[values.length - 1]; result = checkResult(command, expected, output); LOG.info( "Command '" + command.getSeleniumCommand() + "' returned '" + output + "' => " + (result ? "ok" : "not ok, expected '" + expected + "'")); } else { LOG.info("Command '" + command.getSeleniumCommand() + "' returned '" + output + "'"); } } if (screenCapture.requireScreenshot(command, result)) { screenCapture.captureScreenshot(methodName, values); } if (!result && command.isAssertCommand()) { if (stopBrowserOnAssertion) { stopBrowser(); } throw new AssertionAndStopTestError(output); } return result; }