Search in sources :

Example 51 with ScreenShot

use of com.seleniumtests.driver.screenshots.ScreenShot in project seleniumRobot by bhecquet.

the class TestTestStep method testListAllAttachments.

/**
 * Check we get all files from a step and its sub steps
 *
 * @throws IOException
 */
@Test(groups = { "ut" })
public void testListAllAttachments() throws IOException {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    // create screenshot for main step
    ScreenShot screenshot1 = new ScreenShot();
    File tmpImgFile = File.createTempFile("img", ".png");
    File tmpImgFile2 = Paths.get(tmpImgFile.getParent(), "screenshots", tmpImgFile.getName()).toFile();
    FileUtils.moveFile(tmpImgFile, tmpImgFile2);
    File tmpHtmlFile = File.createTempFile("html", ".html");
    File tmpHtmlFile2 = Paths.get(tmpHtmlFile.getParent(), "htmls", tmpHtmlFile.getName()).toFile();
    FileUtils.moveFile(tmpHtmlFile, tmpHtmlFile2);
    tmpImgFile.deleteOnExit();
    tmpHtmlFile.deleteOnExit();
    screenshot1.setOutputDirectory(tmpImgFile.getParent());
    screenshot1.setLocation("http://mysite.com");
    screenshot1.setTitle("mysite");
    screenshot1.setImagePath("screenshots/" + tmpImgFile2.getName());
    screenshot1.setHtmlSourcePath("htmls/" + tmpHtmlFile2.getName());
    step.addSnapshot(new Snapshot(screenshot1, "main", SnapshotCheckType.FALSE), 0, null);
    TestStep subStep = new TestStep("subStep", null, new ArrayList<>(), true);
    // create screenshot for sub step
    ScreenShot screenshot2 = new ScreenShot();
    File tmpImgFile3 = File.createTempFile("img", ".png");
    File tmpImgFile4 = Paths.get(tmpImgFile3.getParent(), "screenshots", tmpImgFile3.getName()).toFile();
    FileUtils.moveFile(tmpImgFile3, tmpImgFile4);
    screenshot2.setOutputDirectory(tmpImgFile3.getParent());
    screenshot2.setLocation("http://mysite.com");
    screenshot2.setTitle("mysite");
    screenshot2.setImagePath("screenshots/" + tmpImgFile4.getName());
    subStep.addSnapshot(new Snapshot(screenshot2, "main", SnapshotCheckType.TRUE), 0, null);
    subStep.addAction(new TestAction("action1", true, new ArrayList<>()));
    step.addAction(new TestAction("action2", false, new ArrayList<>()));
    step.addAction(subStep);
    List<File> attachments = step.getAllAttachments();
    Assert.assertEquals(attachments.size(), 3);
    Assert.assertEquals(attachments.get(0).getName(), "N-A_0-1_step1--" + tmpHtmlFile2.getName().substring(tmpHtmlFile2.getName().length() - 10));
    Assert.assertEquals(attachments.get(1).getName(), "N-A_0-1_step1--" + tmpImgFile2.getName().substring(tmpImgFile2.getName().length() - 10));
    Assert.assertEquals(attachments.get(2).getName(), "N-A_0-1_subStep--" + tmpImgFile4.getName().substring(tmpImgFile4.getName().length() - 10));
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Snapshot(com.seleniumtests.reporter.logger.Snapshot) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) ArrayList(java.util.ArrayList) File(java.io.File) GenericFile(com.seleniumtests.reporter.logger.GenericFile) TestAction(com.seleniumtests.reporter.logger.TestAction) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 52 with ScreenShot

use of com.seleniumtests.driver.screenshots.ScreenShot in project seleniumRobot by bhecquet.

the class TestTestStep method testDurationWithSnapshot.

@Test(groups = { "ut" })
public void testDurationWithSnapshot() {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true);
    step.setDuration(5000L);
    step.setDurationToExclude(500L);
    ScreenShot screenshot = new ScreenShot();
    screenshot.setDuration(200);
    Snapshot snapshot = new Snapshot(screenshot, "main", SnapshotCheckType.TRUE);
    step.addSnapshot(snapshot, 0, "name");
    Assert.assertEquals(step.getDuration(), (Long) 4300L);
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) Snapshot(com.seleniumtests.reporter.logger.Snapshot) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 53 with ScreenShot

use of com.seleniumtests.driver.screenshots.ScreenShot in project seleniumRobot by bhecquet.

the class TestScreenshot method testGetImageNameNull.

@Test(groups = { "ut" })
public void testGetImageNameNull() {
    ScreenShot s = new ScreenShot(null);
    Assert.assertEquals(s.getImageName(), "");
}
Also used : ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 54 with ScreenShot

use of com.seleniumtests.driver.screenshots.ScreenShot in project seleniumRobot by bhecquet.

the class TestScreenshot method testRelocateExistingHtmlFile.

/**
 * Check no error is raised if file already exists
 * @throws IOException
 */
@Test(groups = { "ut" })
public void testRelocateExistingHtmlFile() throws IOException {
    FileUtils.deleteDirectory(new File(SeleniumTestsContextManager.getThreadContext().getOutputDirectory()));
    FileUtils.deleteDirectory(Paths.get(SeleniumTestsContextManager.getThreadContext().getDefaultOutputDirectory(), "out").toFile());
    FileUtils.copyFile(createFileFromResource("tu/test.html"), Paths.get(SeleniumTestsContextManager.getThreadContext().getOutputDirectory(), ScreenshotUtil.HTML_DIR, "foo.html").toFile());
    FileUtils.copyFile(createFileFromResource("tu/test.html"), Paths.get(SeleniumTestsContextManager.getThreadContext().getDefaultOutputDirectory(), "out", ScreenshotUtil.HTML_DIR, "foo.html").toFile());
    ScreenShot s = new ScreenShot();
    s.setHtmlSourcePath(ScreenshotUtil.HTML_DIR + "/foo.html");
    s.relocate(Paths.get(SeleniumTestsContextManager.getThreadContext().getDefaultOutputDirectory(), "out").toString());
}
Also used : ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 55 with ScreenShot

use of com.seleniumtests.driver.screenshots.ScreenShot in project seleniumRobot by bhecquet.

the class TestScreenshot method testGetFullHtmlPath.

@Test(groups = { "ut" })
public void testGetFullHtmlPath() {
    ScreenShot s = new ScreenShot("foo.jpg");
    s.setHtmlSourcePath("foo.html");
    Assert.assertEquals(s.getFullHtmlPath(), SeleniumTestsContextManager.getThreadContext().getOutputDirectory() + "/foo.html");
}
Also used : ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

ScreenShot (com.seleniumtests.driver.screenshots.ScreenShot)63 Test (org.testng.annotations.Test)45 File (java.io.File)37 GenericTest (com.seleniumtests.GenericTest)35 Snapshot (com.seleniumtests.reporter.logger.Snapshot)24 TestStep (com.seleniumtests.reporter.logger.TestStep)24 ArrayList (java.util.ArrayList)14 ScreenshotUtil (com.seleniumtests.driver.screenshots.ScreenshotUtil)10 GenericFile (com.seleniumtests.reporter.logger.GenericFile)8 GenericMultiBrowserTest (com.seleniumtests.it.driver.support.GenericMultiBrowserTest)6 BeforeMethod (org.testng.annotations.BeforeMethod)6 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)5 TestAction (com.seleniumtests.reporter.logger.TestAction)5 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)3 BasicIssue (com.atlassian.jira.rest.client.api.domain.BasicIssue)2 User (com.atlassian.jira.rest.client.api.domain.User)2 IssueInput (com.atlassian.jira.rest.client.api.domain.input.IssueInput)2 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)2 ScenarioException (com.seleniumtests.customexception.ScenarioException)2 SnapshotTarget (com.seleniumtests.driver.screenshots.SnapshotTarget)2