Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add capturing of a html dump after failing a test #6598

Merged
merged 4 commits into from
Oct 5, 2017

Conversation

musienko-maxim
Copy link
Contributor

@musienko-maxim musienko-maxim commented Oct 5, 2017

What does this PR do?

Sometimes for investigating problems with failed tests the screenshots and exceptions may be not enough. This PR provides ability to capture html code from the current page for clarify of reasons of failing some specific usecases.

@benoitf benoitf added the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Oct 5, 2017
@@ -306,9 +307,13 @@ private void captureScreenshot(ITestResult result, SeleniumWebDriver webDriver)
String filename = NameGenerator.generate(testName + "_", 8) + ".png";

try {
String pageSource = webDriver.getPageSource();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a new method to dump page.

@benoitf benoitf added the kind/task Internal things, technical debt, and to-do tasks to be performed. label Oct 5, 2017
Files.createDirectories(dmpDirectory.getParent());
Files.write(dmpDirectory, pageSource.getBytes(), StandardOpenOption.CREATE);
} catch (WebDriverException | IOException e) {
LOG.error(format("Can't capture screenshot for test %s", testName), e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't capture dump

@@ -321,6 +322,19 @@ private void captureScreenshot(ITestResult result, SeleniumWebDriver webDriver)
}
}

private void dumpHtmlCodeFromTheCurrentPage(ITestResult result, SeleniumWebDriver webDriver) {
String testName = result.getTestClass().getName() + "." + result.getMethod().getMethodName();
String filename = NameGenerator.generate(testName + "_", 8) + ".png";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why png?

@musienko-maxim musienko-maxim force-pushed the add_html_dump_after_failing_test branch from 3663cb3 to 83e7037 Compare October 5, 2017 13:40
@musienko-maxim musienko-maxim force-pushed the add_html_dump_after_failing_test branch from 83e7037 to 6f0191a Compare October 5, 2017 13:42
@@ -257,6 +258,7 @@ private void captureScreenshot(ITestResult result) {

collectInjectedWebDrivers(testInstance, webDrivers);
webDrivers.forEach(webDriver -> captureScreenshot(result, webDriver));
webDrivers.forEach(webDriver -> dumpHtmlCodeFromTheCurrentPage(result, webDriver));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not good name for method for because you not just capture screenshot but basically ok for me

@musienko-maxim
Copy link
Contributor Author

ci-build

@musienko-maxim musienko-maxim merged commit 31feab8 into master Oct 5, 2017
@musienko-maxim musienko-maxim deleted the add_html_dump_after_failing_test branch October 5, 2017 15:33
@benoitf benoitf added this to the 5.19.0 milestone Oct 5, 2017
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Oct 5, 2017
@codenvy-ci
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants