当前位置: 首页>>代码示例>>Java>>正文


Java Logs类代码示例

本文整理汇总了Java中org.openqa.selenium.logging.Logs的典型用法代码示例。如果您正苦于以下问题:Java Logs类的具体用法?Java Logs怎么用?Java Logs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Logs类属于org.openqa.selenium.logging包,在下文中一共展示了Logs类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dumpLog

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
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");		
}
 
开发者ID:redskyit,项目名称:ScriptDriver,代码行数:19,代码来源:RunTests.java

示例2: dumpBrowserLogs

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
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);
	}
}
 
开发者ID:wdsx,项目名称:testing-tools,代码行数:17,代码来源:AbstractWebDriverTest.java

示例3: SeleniumTestResult

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
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));
}
 
开发者ID:sumeetchhetri,项目名称:gatf,代码行数:17,代码来源:SeleniumTest.java

示例4: SeleniumException

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
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));
}
 
开发者ID:sumeetchhetri,项目名称:gatf,代码行数:16,代码来源:SeleniumException.java

示例5: getAvailableLogTypes

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@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");
    });

}
 
开发者ID:yujunliang,项目名称:seleniumcapsules,代码行数:29,代码来源:LogsTest.java

示例6: getSeleniumLog

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@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;
}
 
开发者ID:cerberustesting,项目名称:cerberus-source,代码行数:16,代码来源:WebDriverService.java

示例7: clearlogs

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
public void clearlogs(String logType) {
    Logs logs = manage().logs();
    logs.get(logType);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:5,代码来源:JavaDriver.java

示例8: logs

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@Override
public Logs logs()
{
    return options.logs();
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:6,代码来源:DeviceWebDriver.java

示例9: logs

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@Override
public Logs logs() {
    return delegate.logs();
}
 
开发者ID:MagenTys,项目名称:cinnamon,代码行数:5,代码来源:CinnamonWebDriverOptions.java

示例10: logs

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@Override
public Logs logs() {
    throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
}
 
开发者ID:SenhorCastor,项目名称:InspectorGadget,代码行数:5,代码来源:IGOptions.java

示例11: logs

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@Override
public Logs logs() {
    return new DelegatorLogs();
}
 
开发者ID:viltgroup,项目名称:minium,代码行数:5,代码来源:DelegatorWebDriver.java

示例12: logs

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@Override
public Logs logs() {
    return null;
}
 
开发者ID:viltgroup,项目名称:minium,代码行数:5,代码来源:MockWebDriver.java

示例13: logs

import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
/**
 * 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();
 
开发者ID:JoeUtt,项目名称:menggeqa,代码行数:10,代码来源:WebDriver.java


注:本文中的org.openqa.selenium.logging.Logs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。