本文整理汇总了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");
}
示例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);
}
}
示例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));
}
示例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));
}
示例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");
});
}
示例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;
}
示例7: clearlogs
import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
public void clearlogs(String logType) {
Logs logs = manage().logs();
logs.get(logType);
}
示例8: logs
import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@Override
public Logs logs()
{
return options.logs();
}
示例9: logs
import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@Override
public Logs logs() {
return delegate.logs();
}
示例10: logs
import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@Override
public Logs logs() {
throw new UnsupportedOperationException("NOT YET IMPLEMENTED");
}
示例11: logs
import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@Override
public Logs logs() {
return new DelegatorLogs();
}
示例12: logs
import org.openqa.selenium.logging.Logs; //导入依赖的package包/类
@Override
public Logs logs() {
return null;
}
示例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();