Search in sources :

Example 1 with TestAction

use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.

the class Uft method readStep.

/**
 * Read a step element
 * @param parentStep
 * @param stepElement
 */
private void readStep(TestStep parentStep, Element stepElement) {
    List<Element> stepList = stepElement.getChildren("Step");
    org.jsoup.nodes.Document htmlDoc = Jsoup.parseBodyFragment(stepElement.getChildText("Details"));
    String details = htmlDoc.text();
    String stepDescription = String.format("%s: %s", stepElement.getChildText("Obj"), details);
    if (stepList.isEmpty()) {
        TestAction action = new TestAction(stepDescription, false, new ArrayList<>());
        parentStep.addAction(action);
    } else {
        TestStep stepStep = new TestStep(stepDescription, Reporter.getCurrentTestResult(), new ArrayList<>(), false);
        parentStep.addStep(stepStep);
        for (Element subStepElement : stepElement.getChildren("Step")) {
            readStep(stepStep, subStepElement);
        }
    }
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Element(org.jdom2.Element) TestAction(com.seleniumtests.reporter.logger.TestAction)

Example 2 with TestAction

use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.

the class LogAction method logCompositeAction.

/**
 * Log composite action when they are declared
 * @param joinPoint
 */
@After("this(com.seleniumtests.uipage.PageObject) && " + "call(public org.openqa.selenium.interactions.Actions org.openqa.selenium.interactions.Actions.* (..))")
public void logCompositeAction(JoinPoint joinPoint) {
    List<String> pwdToReplace = new ArrayList<>();
    String actionName = String.format("%s %s", joinPoint.getSignature().getName(), buildArgString(joinPoint, pwdToReplace, new HashMap<>()));
    TestAction currentAction = new TestAction(actionName, false, pwdToReplace);
    if (TestStepManager.getParentTestStep() != null) {
        TestStepManager.getParentTestStep().addAction(currentAction);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TestAction(com.seleniumtests.reporter.logger.TestAction) After(org.aspectj.lang.annotation.After)

Example 3 with TestAction

use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.

the class TestStepManager method logTestStep.

/**
 * Logs the testStep for this test
 * Once logging is done, parentTestStep and currentRootTestStep are reset to avoid storing new data in them
 * @param testStep
 * @param storeStep
 */
public static void logTestStep(TestStep testStep, boolean storeStep) {
    List<TestAction> actionList = testStep.getStepActions();
    if (!actionList.isEmpty()) {
        for (TestAction action : actionList) {
            if (action instanceof TestStep) {
                logTestStep((TestStep) action, false);
            }
        }
    }
    if (storeStep) {
        // notify each TestStepManager about the new test step (useful for AfterClass / AfterTest configuration methods)
        for (SeleniumTestsContext testContext : SeleniumTestsContextManager.getContextForCurrentTestState()) {
            TestStepManager stepManager = testContext.getTestStepManager();
            stepManager.getTestSteps().add(testStep);
            stepManager.setRootTestStep(null);
            stepManager.setRunningTestStep(null);
        }
    }
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) TestAction(com.seleniumtests.reporter.logger.TestAction)

Example 4 with TestAction

use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.

the class TestTestStep method testPasswordMaskingSubStep.

/**
 * Check that if a substep adds password values, parent step is not impacted
 */
@Test(groups = { "ut" })
public void testPasswordMaskingSubStep() {
    TestStep step = new TestStep("step1 with args: (bar, passwd)", null, new ArrayList<>(), true);
    TestStep substep = new TestStep("substep with args: (passwd)", null, Arrays.asList("passwd"), true);
    TestAction action = new TestAction("action in step1 with args: (foo, passwd)", false, new ArrayList<>());
    TestMessage message = new TestMessage("everything OK on passwd", MessageType.INFO);
    step.addAction(substep);
    substep.addAction(action);
    substep.addMessage(message);
    Assert.assertEquals(step.getName(), "step1 with args: (bar, passwd)");
    Assert.assertEquals(action.getName(), "action in step1 with args: (foo, ******)");
    Assert.assertEquals(message.getName(), "everything OK on ******");
    Assert.assertEquals(substep.getName(), "substep with args: (******)");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) TestMessage(com.seleniumtests.reporter.logger.TestMessage) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 5 with TestAction

use of com.seleniumtests.reporter.logger.TestAction in project seleniumRobot by bhecquet.

the class TestTestStep method testTestActionEncodeXml.

@Test(groups = { "ut" })
public void testTestActionEncodeXml() {
    TestAction action = new TestAction("action2 \"'<>&", false, new ArrayList<>());
    TestAction encodedAction = action.encode("xml");
    Assert.assertEquals(encodedAction.toString(), "action2 &quot;&apos;&lt;&gt;&amp;");
}
Also used : TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

TestAction (com.seleniumtests.reporter.logger.TestAction)56 TestStep (com.seleniumtests.reporter.logger.TestStep)47 Test (org.testng.annotations.Test)44 ArrayList (java.util.ArrayList)38 GenericTest (com.seleniumtests.GenericTest)24 TestMessage (com.seleniumtests.reporter.logger.TestMessage)12 DriverExceptions (com.seleniumtests.customexception.DriverExceptions)8 ScreenShot (com.seleniumtests.driver.screenshots.ScreenShot)5 Snapshot (com.seleniumtests.reporter.logger.Snapshot)5 File (java.io.File)5 HashMap (java.util.HashMap)5 GenericFile (com.seleniumtests.reporter.logger.GenericFile)3 Element (org.jdom2.Element)3 WebDriverException (org.openqa.selenium.WebDriverException)3 HarCapture (com.seleniumtests.reporter.logger.HarCapture)2 PageObject (com.seleniumtests.uipage.PageObject)2 Instant (java.time.Instant)2 Har (net.lightbody.bmp.core.har.Har)2 HarLog (net.lightbody.bmp.core.har.HarLog)2 HarPage (net.lightbody.bmp.core.har.HarPage)2