diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-02-04 16:55:12 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-02-04 16:55:12 +0100 |
commit | 394d7c391c6a676f758b840027dd0b70b3942bbd (patch) | |
tree | c755a838d5a78bd70eb3b46ef2f02a4a690e5ccb /it/it-tests/src/test/java/util | |
parent | cc1d7e87b5a7ad6176fbf812bc29175d8cafc7db (diff) | |
parent | f0dd332463ae0fcab921ea97699c68a3913585c7 (diff) | |
download | sonarqube-394d7c391c6a676f758b840027dd0b70b3942bbd.tar.gz sonarqube-394d7c391c6a676f758b840027dd0b70b3942bbd.zip |
Merge pull request #742 from SonarSource/feature/stas/selenium-js-logs
dump js logs in failed selenium tests
Diffstat (limited to 'it/it-tests/src/test/java/util')
-rw-r--r-- | it/it-tests/src/test/java/util/selenium/SeleneseTest.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/it/it-tests/src/test/java/util/selenium/SeleneseTest.java b/it/it-tests/src/test/java/util/selenium/SeleneseTest.java index d4d428dc916..a23cfb5828e 100644 --- a/it/it-tests/src/test/java/util/selenium/SeleneseTest.java +++ b/it/it-tests/src/test/java/util/selenium/SeleneseTest.java @@ -24,6 +24,7 @@ import com.sonar.orchestrator.selenium.Selenese; import java.io.File; import java.io.IOException; import java.net.URI; +import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.regex.Pattern; @@ -34,6 +35,9 @@ import org.jsoup.nodes.Element; import org.openqa.selenium.By; import org.openqa.selenium.NotFoundException; import org.openqa.selenium.WebElement; +import org.openqa.selenium.logging.LogEntries; +import org.openqa.selenium.logging.LogEntry; +import org.openqa.selenium.logging.LogType; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; @@ -70,13 +74,25 @@ public class SeleneseTest { String param1 = tr.child(1).text(); String param2 = tr.child(2).text(); - action(action, param1, param2); + try { + action(action, param1, param2); + } catch (AssertionError e) { + analyzeLog(driver); + throw e; + } } } } } } + private static void analyzeLog(SeleniumDriver driver) { + LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER); + for (LogEntry entry : logEntries) { + System.out.println(new Date(entry.getTimestamp()) + " " + entry.getLevel() + " " + entry.getMessage()); + } + } + private static Document parse(File file) { try { return Jsoup.parse(file, UTF_8.name()); |