Java 类org.openqa.selenium.logging.Logs 实例源码

项目:ScriptDriver    文件:RunTests.java   
private void dumpLog() throws Exception {
    Logs log = driver.manage().logs();
    LogEntries entries = log.get(LogType.BROWSER);
    // System.out.println(entries);
    List<LogEntry> list = entries.getAll();
    boolean fail = false;
    for (int i = 0; i < list.size(); i++) {
        LogEntry e = list.get(i);
        System.out.println(e);
        if (e.getLevel().getName().equals("SEVERE") 
                && e.getMessage().indexOf("Uncaught ") != -1
                && e.getMessage().indexOf(" Error:") != -1) {
            System.out.println("*** Uncaught Error ***");
            fail = true;
        }                       
    }
    if (fail) throw new Exception("Unhandled Exception! Check console log for details");        
}
项目:testing-tools    文件:AbstractWebDriverTest.java   
protected void dumpBrowserLogs(String testName) {
    try {
        Logs logs = webdriver.manage().logs();

        for(String type : logs.getAvailableLogTypes()) {
            String fileName = testName + "_" + type;
            List<LogEntry> allLogs = logs.get(type).getAll();
            if (allLogs.size() > 0) {
                WEBDRIVER_LOGS_DIR_PATH.mkdirs();
                writeLines(new File(WEBDRIVER_LOGS_DIR_PATH, fileName), allLogs);
            }
        }
    } catch (Exception e) {
        logger.error("Cannot dumpBrowserLogs('" + testName + "')", e);
    }
}
项目:gatf    文件:SeleniumTest.java   
public SeleniumTestResult(WebDriver d, SeleniumTest test, Throwable cause, LoggingPreferences ___lp___) {
    this.status = false;
    this.internalTestRes = test.internalTestRs;
    Logs logs = d.manage().logs();
    for (String s : LOG_TYPES_SET) {
        if(!logs.getAvailableLogTypes().contains(s))continue;
        LogEntries logEntries = logs.get(s);
        if(logEntries!=null && !logEntries.getAll().isEmpty()) {
            this.logs.put(s, new SerializableLogEntries(logEntries.getAll())); 
        }
    }
    List<LogEntry> entries = new ArrayList<LogEntry>();
    entries.add(new LogEntry(Level.ALL, new Date().getTime(), cause.getMessage()));
    entries.add(new LogEntry(Level.ALL, new Date().getTime(), ExceptionUtils.getStackTrace(cause)));
    this.logs.put("gatf", new SerializableLogEntries(entries));
}
项目:gatf    文件:SeleniumTest.java   
public SeleniumTestResult(WebDriver d, SeleniumTest test, LoggingPreferences ___lp___)
{
    this.status = true;
    this.internalTestRes = test.internalTestRs;
    Logs logs = d.manage().logs();
    for (String s : LOG_TYPES_SET) {
        if(!logs.getAvailableLogTypes().contains(s))continue;
        LogEntries logEntries = logs.get(s);
        if(logEntries!=null && !logEntries.getAll().isEmpty()) {
            this.logs.put(s, new SerializableLogEntries(logEntries.getAll())); 
        }
    }
}
项目:gatf    文件:SeleniumException.java   
public SeleniumException(WebDriver d, Throwable cause, SeleniumTest test) {
    super(cause);
    Map<String, SerializableLogEntries> lg = new HashMap<String, SerializableLogEntries>();
       Logs logs = d.manage().logs();
       for (String s : d.manage().logs().getAvailableLogTypes()) {
           LogEntries logEntries = logs.get(s);
           if(!logEntries.getAll().isEmpty()) {
               lg.put(s, new SerializableLogEntries(logEntries.getAll())); 
           }
       }
       List<LogEntry> entries = new ArrayList<LogEntry>();
       entries.add(new LogEntry(Level.ALL, new Date().getTime(), cause.getMessage()));
       entries.add(new LogEntry(Level.ALL, new Date().getTime(), ExceptionUtils.getStackTrace(cause)));
       lg.put("gatf", new SerializableLogEntries(entries));
}
项目:seleniumcapsules    文件:LogsTest.java   
@Test
public void getAvailableLogTypes() {
    WebDriver driver = new ChromeDriver();
    driver.get("http://ticketfly.com");

    Options manage = driver.manage();
    Logs logs = manage.logs();
    Set<String> availableLogTypes = logs.getAvailableLogTypes();
    System.out.println(availableLogTypes);
    availableLogTypes.stream().forEach(logType -> {
        System.out.println("logType=" + logType);
        LogEntries logEntries = logs.get(logType);
        List<LogEntry> all = logEntries.getAll();
        all.forEach(entry -> {
            System.out.println(entry.getLevel());
            System.out.println(entry.getMessage());
            System.out.println(entry.getTimestamp());
            System.out.println(entry.toMap());
            System.out.println(entry);
        });

        List<LogEntry> filter = logEntries.filter(Level.SEVERE);
        System.out.println("After filtering");
        filter.forEach(System.out::println);
        System.out.println("Done");
    });

}
项目:cerberus-source    文件:WebDriverService.java   
@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;
}
项目:marathonv5    文件:JavaDriver.java   
public void clearlogs(String logType) {
    Logs logs = manage().logs();
    logs.get(logType);
}
项目:xframium-java    文件:DeviceWebDriver.java   
@Override
public Logs logs()
{
    return options.logs();
}
项目:cinnamon    文件:CinnamonWebDriverOptions.java   
@Override
public Logs logs() {
    return delegate.logs();
}
项目:InspectorGadget    文件:IGOptions.java   
@Override
public Logs logs() {
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
}
项目:minium    文件:DelegatorWebDriver.java   
@Override
public Logs logs() {
    return new DelegatorLogs();
}
项目:minium    文件:MockWebDriver.java   
@Override
public Logs logs() {
    return null;
}
项目:menggeqa    文件:WebDriver.java   
/**
 * Gets the {@link Logs} interface used to fetch different types of logs.
 * <p>
 * <p>To set the logging preferences {@link LoggingPreferences}.
 *
 * @return A Logs interface.
 */
@Beta
Logs logs();