Search in sources :

Example 61 with TestStep

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

the class TestHtmlElement method testIsDisplayedExceptionSetStepFailed.

/**
 * check correction of issue #10': step should be failed for all other actions
 * but waitForPresent
 *
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testIsDisplayedExceptionSetStepFailed() throws Exception {
    TestStep step = new TestStep("step 1", null, new ArrayList<>(), true);
    TestStepManager.setParentTestStep(step);
    SeleniumTestsContextManager.getThreadContext().setReplayTimeout(1);
    when(element.isDisplayed()).thenThrow(new WebDriverException("error"));
    Assert.assertFalse(el.isDisplayed());
    Assert.assertEquals(step.getStepStatus(), StepStatus.WARNING);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) WebDriverException(org.openqa.selenium.WebDriverException) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 62 with TestStep

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

the class TestHtmlElement method testIsPresentExceptionDoNotSetStepFailed.

/**
 * Check that when using isElementPresent, step is not marked as failed. So
 * report will show step as green check correction of issue #104
 *
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testIsPresentExceptionDoNotSetStepFailed() throws Exception {
    TestStep step = new TestStep("step 1", null, new ArrayList<>(), true);
    TestStepManager.setParentTestStep(step);
    SeleniumTestsContextManager.getThreadContext().setReplayTimeout(1);
    when(driver.findElement(By.id("el"))).thenThrow(new NoSuchElementException(""));
    Assert.assertEquals(el.isElementPresent(1), false);
    Assert.assertEquals(step.getStepStatus(), StepStatus.SUCCESS);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) NoSuchElementException(org.openqa.selenium.NoSuchElementException) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 63 with TestStep

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

the class TestTestStep method testTestSubFilePositionAndParent.

@Test(groups = { "ut" })
public void testTestSubFilePositionAndParent() throws IOException {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    TestStep subStep = new TestStep("subStep1", null, new ArrayList<>(), true);
    step.addStep(subStep);
    GenericFile file = new GenericFile(File.createTempFile("video", ".avi"), "video file");
    step.addFile(file);
    Assert.assertEquals(file.getPosition(), 1);
    Assert.assertEquals(file.getParent(), step);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) GenericFile(com.seleniumtests.reporter.logger.GenericFile) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 64 with TestStep

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

the class TestTestStep method testTestSubSnapshotPositionAndParent.

@Test(groups = { "ut" })
public void testTestSubSnapshotPositionAndParent() throws IOException {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    TestStep subStep = new TestStep("subStep1", null, new ArrayList<>(), true);
    step.addStep(subStep);
    ScreenShot screenshot = new ScreenShot();
    File tmpImgFile = File.createTempFile("img", ".png");
    File tmpHtmlFile = File.createTempFile("html", ".html");
    screenshot.setOutputDirectory(tmpImgFile.getParent());
    screenshot.setLocation("http://mysite.com");
    screenshot.setTitle("mysite");
    screenshot.setImagePath(tmpImgFile.getName());
    screenshot.setHtmlSourcePath(tmpHtmlFile.getName());
    Snapshot snapshot = new Snapshot(screenshot, "main", SnapshotCheckType.TRUE);
    step.addSnapshot(snapshot, 0, null);
    Assert.assertEquals(snapshot.getPosition(), 0);
    Assert.assertEquals(snapshot.getParent(), step);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Snapshot(com.seleniumtests.reporter.logger.Snapshot) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) File(java.io.File) GenericFile(com.seleniumtests.reporter.logger.GenericFile) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 65 with TestStep

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

the class TestTestStep method testTestStepEncodeUnexpected.

@Test(groups = { "ut" }, expectedExceptions = CustomSeleniumTestsException.class)
public void testTestStepEncodeUnexpected() {
    TestStep step = new TestStep("step1 \"'<>&", null, new ArrayList<>(), true);
    step.encode("wrongFormat");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

TestStep (com.seleniumtests.reporter.logger.TestStep)190 Test (org.testng.annotations.Test)148 GenericTest (com.seleniumtests.GenericTest)120 ArrayList (java.util.ArrayList)80 TestAction (com.seleniumtests.reporter.logger.TestAction)47 File (java.io.File)37 ScreenShot (com.seleniumtests.driver.screenshots.ScreenShot)25 Snapshot (com.seleniumtests.reporter.logger.Snapshot)24 ErrorCause (com.seleniumtests.core.testanalysis.ErrorCause)19 TestMessage (com.seleniumtests.reporter.logger.TestMessage)16 GenericFile (com.seleniumtests.reporter.logger.GenericFile)15 MockitoTest (com.seleniumtests.MockitoTest)12 HashMap (java.util.HashMap)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 ITestResult (org.testng.ITestResult)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 Uft (com.seleniumtests.connectors.extools.Uft)8 DriverExceptions (com.seleniumtests.customexception.DriverExceptions)8 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)7 SeleniumRobotServerException (com.seleniumtests.customexception.SeleniumRobotServerException)6