use of com.neotys.selenium.proxies.NLWebDriver in project seleniumRobot by bhecquet.
the class TestTasks method terminateCurrentStep.
public static void terminateCurrentStep() {
NLWebDriver neoloadDriver = WebUIDriver.getNeoloadDriver();
// log the previous step if it exists and create the new one
TestStep previousStep = TestStepManager.getCurrentRootTestStep();
if (previousStep != null) {
previousStep.updateDuration();
TestStepManager.logTestStep(previousStep);
if (neoloadDriver != null) {
neoloadDriver.stopTransaction();
}
}
}
use of com.neotys.selenium.proxies.NLWebDriver in project seleniumRobot by bhecquet.
the class LogAction method commonLogTestStep.
/**
* Log a TestStep, inside a parent TestStep or not
* Common method used for all test step logging
* @return
* @throws Throwable
*/
private Object commonLogTestStep(ProceedingJoinPoint joinPoint, String stepNamePrefix, boolean configStep) throws Throwable {
Object reply = null;
boolean rootStep = false;
TestStep previousParent = null;
// step name will contain method arguments only if it's not a configuration method (as they are generic)
TestStep currentStep = buildRootStep(joinPoint, stepNamePrefix, !configStep);
if ("openPage".equals(joinPoint.getSignature().getName()) && joinPoint.getTarget() instanceof PageObject) {
PageObject page = (PageObject) joinPoint.getTarget();
currentStep.addAction(new TestAction(String.format("Opening page %s", page.getClass().getSimpleName()), false, new ArrayList<>()));
}
BrowserMobProxy mobProxy = WebUIDriver.getBrowserMobProxy();
NLWebDriver neoloadDriver = WebUIDriver.getNeoloadDriver();
VideoRecorder videoRecorder = WebUIDriver.getThreadVideoRecorder();
// if rootStep is null, parent step is also null
if (TestStepManager.getCurrentRootTestStep() == null) {
// will also set parent step
TestStepManager.setCurrentRootTestStep(currentStep);
rootStep = true;
if (mobProxy != null) {
mobProxy.newPage(currentStep.getName());
}
if (videoRecorder != null) {
CustomEventFiringWebDriver.displayStepOnScreen(currentStep.getName(), SeleniumTestsContextManager.getThreadContext().getRunMode(), SeleniumTestsContextManager.getThreadContext().getSeleniumGridConnector(), videoRecorder);
}
if (neoloadDriver != null) {
neoloadDriver.startTransaction(currentStep.getName());
}
} else {
TestStepManager.getParentTestStep().addStep(currentStep);
previousParent = TestStepManager.getParentTestStep();
TestStepManager.setParentTestStep(currentStep);
}
// set the start date once step is initialized so that when we get the video frame associated to step, step name displayed on screen is the same as the running step name
currentStep.setStartDate();
try {
reply = joinPoint.proceed(joinPoint.getArgs());
} catch (Throwable e) {
currentStep.setFailed(true);
currentStep.setActionException(e);
// issue #287 (https://github.com/cbeust/testng/issues/2148): is method an @AfterMethod. Then do not rethrow exception
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
if (methodSignature.getMethod().getAnnotation(AfterMethod.class) != null) {
scenarioLogger.error(String.format("Error in @AfterMethod %s: %s", methodSignature, e.getMessage()));
} else {
throw e;
}
} finally {
if (rootStep) {
TestStepManager.getCurrentRootTestStep().updateDuration();
TestStepManager.logTestStep(TestStepManager.getCurrentRootTestStep());
if (neoloadDriver != null) {
neoloadDriver.stopTransaction();
}
} else {
TestStepManager.setParentTestStep(previousParent);
}
}
return reply;
}
use of com.neotys.selenium.proxies.NLWebDriver in project seleniumRobot by bhecquet.
the class TestTasks method addStep.
/**
* Add step to test and add snapshot to it
* If a previous step exists, store it
* @param stepName name of the step
* If name is null, only previous step is stored, no new step is created
* @param passwordsToMask array of strings that must be replaced by '*****' in reports
*/
public static void addStep(String stepName, String... passwordsToMask) {
if (!SeleniumTestsContextManager.getThreadContext().isManualTestSteps()) {
throw new ConfigurationException("manual steps can only be used when automatic steps are disabled ('manualTestSteps' option set to true)");
}
NLWebDriver neoloadDriver = WebUIDriver.getNeoloadDriver();
// log the previous step if it exists and create the new one
terminateCurrentStep();
// stepName is null when test is terminating. We don't create a new step
if (stepName != null) {
TestStep step = new TestStep(stepName, Reporter.getCurrentTestResult(), Arrays.asList(passwordsToMask), SeleniumTestsContextManager.getThreadContext().getMaskedPassword());
TestStepManager.setCurrentRootTestStep(step);
capturePageSnapshot();
// start a new page when using BrowserMobProxy (network capture)
BrowserMobProxy mobProxy = WebUIDriver.getBrowserMobProxy();
if (mobProxy != null) {
mobProxy.newPage(stepName);
}
// start a new transaction when using Neoload
if (neoloadDriver != null) {
neoloadDriver.startTransaction(stepName);
}
}
}
Aggregations