Search in sources :

Example 6 with LogEntry

use of org.openqa.selenium.logging.LogEntry in project cerberus-source by cerberustesting.

the class WebDriverService method getSeleniumLog.

@Override
public List<String> getSeleniumLog(Session session) {
    List<String> result = new ArrayList();
    Logs logs = session.getDriver().manage().logs();
    for (String logType : logs.getAvailableLogTypes()) {
        LogEntries logEntries = logs.get(logType);
        result.add("********************" + logType + "********************\n");
        for (LogEntry logEntry : logEntries) {
            result.add(new Date(logEntry.getTimestamp()) + " : " + logEntry.getLevel() + " : " + logEntry.getMessage() + "\n");
        }
    }
    return result;
}
Also used : LogEntries(org.openqa.selenium.logging.LogEntries) ArrayList(java.util.ArrayList) Logs(org.openqa.selenium.logging.Logs) LogEntry(org.openqa.selenium.logging.LogEntry) Date(java.util.Date)

Example 7 with LogEntry

use of org.openqa.selenium.logging.LogEntry in project blueocean-plugin by jenkinsci.

the class ATHJUnitRunner method outputConsoleLogs.

private void outputConsoleLogs() {
    WebDriver driver = injector.getInstance(WebDriver.class);
    List<LogEntry> allEntries = driver.manage().logs().get("browser").getAll();
    LogEntryLogger.recordLogEntries(allEntries);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) LogEntry(org.openqa.selenium.logging.LogEntry)

Example 8 with LogEntry

use of org.openqa.selenium.logging.LogEntry in project flow by vaadin.

the class EmptyListsIT method emptyListsAreProperlyHandled.

@Test
public void emptyListsAreProperlyHandled() {
    open();
    TestBenchElement template = $("*").id("template");
    Assert.assertTrue(template.$("*").attributeContains("class", "item").exists());
    findElement(By.id("set-empty")).click();
    LogEntries logs = driver.manage().logs().get("browser");
    if (logs != null) {
        Optional<LogEntry> anyError = StreamSupport.stream(logs.spliterator(), true).filter(entry -> entry.getLevel().intValue() > java.util.logging.Level.INFO.intValue()).filter(entry -> !entry.getMessage().contains("favicon.ico")).filter(entry -> !entry.getMessage().contains("HTML Imports is deprecated")).filter(entry -> !entry.getMessage().contains("sockjs-node")).filter(entry -> !entry.getMessage().contains("[WDS] Disconnected!")).filter(entry -> !entry.getMessage().contains("WebSocket connection to 'ws://")).findAny();
        anyError.ifPresent(entry -> Assert.fail(entry.getMessage()));
    }
}
Also used : LogEntries(org.openqa.selenium.logging.LogEntries) TestBenchElement(com.vaadin.testbench.TestBenchElement) LogEntry(org.openqa.selenium.logging.LogEntry) By(org.openqa.selenium.By) Optional(java.util.Optional) StreamSupport(java.util.stream.StreamSupport) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest) Assert(org.junit.Assert) LogEntries(org.openqa.selenium.logging.LogEntries) TestBenchElement(com.vaadin.testbench.TestBenchElement) LogEntry(org.openqa.selenium.logging.LogEntry) Test(org.junit.Test) ChromeBrowserTest(com.vaadin.flow.testutil.ChromeBrowserTest)

Example 9 with LogEntry

use of org.openqa.selenium.logging.LogEntry in project chrome_page_performance_sqlite_java by sergueik.

the class ChromePagePerformanceUtilTest method afterMethod.

@After
public void afterMethod() {
    System.err.println("After Method:");
    int cnt = 0;
    int maxCnt = 5;
    LogEntries logEntries = driver.manage().logs().get(LogType.PERFORMANCE);
    for (LogEntry logEntry : logEntries) {
        if (cnt++ > maxCnt) {
            break;
        }
        // System.err.println("Log entry: " + logEntry.getMessage());
        System.err.println(String.format("Log entry %d: ", cnt));
        Map<String, Object> o = (Map<String, Object>) logEntry.toJson();
        JSONObject logEntryJSONObject = new JSONObject(o.get("message"));
        Iterator<String> logEntryKeys = logEntryJSONObject.keys();
        while (logEntryKeys.hasNext()) {
            String logEntryKey = logEntryKeys.next();
            System.err.println(logEntryKey);
        }
    }
}
Also used : LogEntries(org.openqa.selenium.logging.LogEntries) JSONObject(org.json.JSONObject) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map) LogEntry(org.openqa.selenium.logging.LogEntry) After(org.junit.After)

Example 10 with LogEntry

use of org.openqa.selenium.logging.LogEntry in project scout.rt by eclipse.

the class BrowserLogRule method finished.

@Override
protected void finished(Description description) {
    Date end = new Date();
    long duration = end.getTime() - m_start.getTime();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    LogEntries logEntries = m_driver.manage().logs().get(LogType.BROWSER);
    for (LogEntry logEntry : logEntries) {
        System.out.println(sdf.format(new Date(logEntry.getTimestamp())) + " " + logEntry.getLevel() + " " + logEntry.getMessage());
    }
    System.out.println(MessageFormat.format("^ | {1}.{2} [{0}] (took {3} ms)", sdf.format(end), description.getClassName(), description.getMethodName(), duration));
}
Also used : LogEntries(org.openqa.selenium.logging.LogEntries) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LogEntry(org.openqa.selenium.logging.LogEntry)

Aggregations

LogEntry (org.openqa.selenium.logging.LogEntry)12 LogEntries (org.openqa.selenium.logging.LogEntries)8 WebDriver (org.openqa.selenium.WebDriver)5 Test (org.junit.Test)4 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)4 File (java.io.File)3 PrintWriter (java.io.PrintWriter)3 ChromeBrowserTest (com.vaadin.flow.testutil.ChromeBrowserTest)2 CompileOptions (de.mirkosertic.bytecoder.backend.CompileOptions)2 CompileTarget (de.mirkosertic.bytecoder.backend.CompileTarget)2 BytecodeMethodSignature (de.mirkosertic.bytecoder.core.BytecodeMethodSignature)2 BytecodeObjectTypeRef (de.mirkosertic.bytecoder.core.BytecodeObjectTypeRef)2 ControlFlowProcessingException (de.mirkosertic.bytecoder.ssa.ControlFlowProcessingException)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Optional (java.util.Optional)2 StreamSupport (java.util.stream.StreamSupport)2 Assert (org.junit.Assert)2