Repository: tapestry-5
Updated Branches:
  refs/heads/master 6d69eb9a7 -> a580c7b60


use webdriver in error reporter


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/a580c7b6
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/a580c7b6
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/a580c7b6

Branch: refs/heads/master
Commit: a580c7b607e575c9daee0110af7b0c537b11c55a
Parents: 6d69eb9
Author: Jochen Kemnade <jkemn...@apache.org>
Authored: Tue Oct 24 10:44:50 2017 +0200
Committer: Jochen Kemnade <jkemn...@apache.org>
Committed: Tue Oct 24 10:45:39 2017 +0200

----------------------------------------------------------------------
 .../apache/tapestry5/test/ErrorReporterImpl.java | 19 ++++++++++---------
 .../apache/tapestry5/test/SeleniumTestCase.java  |  2 +-
 2 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a580c7b6/tapestry-test/src/main/java/org/apache/tapestry5/test/ErrorReporterImpl.java
----------------------------------------------------------------------
diff --git 
a/tapestry-test/src/main/java/org/apache/tapestry5/test/ErrorReporterImpl.java 
b/tapestry-test/src/main/java/org/apache/tapestry5/test/ErrorReporterImpl.java
index ef44a61..d584e79 100644
--- 
a/tapestry-test/src/main/java/org/apache/tapestry5/test/ErrorReporterImpl.java
+++ 
b/tapestry-test/src/main/java/org/apache/tapestry5/test/ErrorReporterImpl.java
@@ -14,13 +14,16 @@
 
 package org.apache.tapestry5.test;
 
-import com.thoughtworks.selenium.CommandProcessor;
+import org.openqa.selenium.OutputType;
+import org.openqa.selenium.TakesScreenshot;
+import org.openqa.selenium.WebDriver;
 import org.testng.ITestContext;
 
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.lang.reflect.Method;
+import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -28,7 +31,7 @@ import java.util.Set;
 
 public class ErrorReporterImpl implements ErrorReporter
 {
-    private final CommandProcessor commandProcessor;
+    private final WebDriver webdriver;
 
     private final ITestContext testContext;
 
@@ -38,9 +41,9 @@ public class ErrorReporterImpl implements ErrorReporter
 
     private final List<File> outputPaths = new ArrayList<File>();
 
-    public ErrorReporterImpl(CommandProcessor commandProcessor, ITestContext 
testContext)
+    public ErrorReporterImpl(WebDriver webdriver, ITestContext testContext)
     {
-        this.commandProcessor = commandProcessor;
+        this.webdriver = webdriver;
         this.testContext = testContext;
     }
 
@@ -69,8 +72,7 @@ public class ErrorReporterImpl implements ErrorReporter
     @Override
     public void writeErrorReport(String reportText)
     {
-        String htmlSource = commandProcessor.getString("getHtmlSource", new 
String[]
-                {});
+        String htmlSource = webdriver.getPageSource();
 
         File dir = new File(testContext.getOutputDirectory());
 
@@ -107,9 +109,8 @@ public class ErrorReporterImpl implements ErrorReporter
 
         try
         {
-            commandProcessor.doCommand("captureEntirePageScreenshot", new 
String[]
-                    {capture.getAbsolutePath(), "background=white"});
-
+            byte[] screenshotBytes = ((TakesScreenshot) 
webdriver).getScreenshotAs(OutputType.BYTES);
+            Files.write(capture.toPath(), screenshotBytes);
             outputPaths.add(capture);
         } catch (Exception ex)
         {

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a580c7b6/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
----------------------------------------------------------------------
diff --git 
a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java 
b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
index 5f9419e..2af5575 100644
--- 
a/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
+++ 
b/tapestry-test/src/main/java/org/apache/tapestry5/test/SeleniumTestCase.java
@@ -230,7 +230,7 @@ public abstract class SeleniumTestCase extends Assert 
implements Selenium
         CommandProcessor webDriverCommandProcessor = new 
WebDriverCommandProcessor(baseURL, driver);
 
 
-        final ErrorReporterImpl errorReporter = new 
ErrorReporterImpl(webDriverCommandProcessor, testContext);
+        final ErrorReporterImpl errorReporter = new ErrorReporterImpl(driver, 
testContext);
 
         ErrorReportingCommandProcessor commandProcessor = new 
ErrorReportingCommandProcessor(webDriverCommandProcessor,
                 errorReporter);

Reply via email to