-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
@@ -306,9 +307,13 @@ private void captureScreenshot(ITestResult result, SeleniumWebDriver webDriver) | |||
String filename = NameGenerator.generate(testName + "_", 8) + ".png"; | |||
|
|||
try { | |||
String pageSource = webDriver.getPageSource(); |
There was a problem hiding this comment.
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.
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); |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why png?
3663cb3
to
83e7037
Compare
83e7037
to
6f0191a
Compare
@@ -257,6 +258,7 @@ private void captureScreenshot(ITestResult result) { | |||
|
|||
collectInjectedWebDrivers(testInstance, webDrivers); | |||
webDrivers.forEach(webDriver -> captureScreenshot(result, webDriver)); | |||
webDrivers.forEach(webDriver -> dumpHtmlCodeFromTheCurrentPage(result, webDriver)); |
There was a problem hiding this comment.
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
ci-build |
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/4023/ |
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.