adding logs access
diff --git a/lib/src/logs.dart b/lib/src/logs.dart
new file mode 100644
index 0000000..bae5c96
--- /dev/null
+++ b/lib/src/logs.dart
@@ -0,0 +1,38 @@
+part of webdriver;
+
+class Logs extends _WebDriverBase {
+ Logs._(driver) : super(driver, 'log');
+
+ Future<Iterable<LogEntry>> get(String logType) async =>
+ (await _post('', {'type': logType})).map(
+ (entry) => new LogEntry.fromMap(entry));
+}
+
+class LogEntry {
+ final String message;
+ final int timestamp;
+ final String level;
+
+ const LogEntry(this.message, this.timestamp, this.level);
+
+ LogEntry.fromMap(Map map)
+ : this(map['message'], map['timestamp'], map['level']);
+}
+
+class LogType {
+ static const String BROWSER = 'browser';
+ static const String CLIENT = 'client';
+ static const String DRIVER = 'driver';
+ static const String PERFORMANCE = 'performance';
+ static const String PROFILER = 'profiler';
+ static const String SERVER = 'server';
+}
+
+class LogLevel {
+ static const String OFF = 'OFF';
+ static const String SEVERE = 'SEVERE';
+ static const String WARNING = 'WARNING';
+ static const String INFO = 'INFO';
+ static const String DEBUG = 'DEBUG';
+ static const String ALL = 'ALL';
+}
\ No newline at end of file
diff --git a/lib/src/web_driver.dart b/lib/src/web_driver.dart
index 763dca2..6916d12 100644
--- a/lib/src/web_driver.dart
+++ b/lib/src/web_driver.dart
@@ -144,6 +144,8 @@
Navigation get navigate => new Navigation._(this);
Cookies get cookies => new Cookies._(this);
+
+ Logs get logs => new Logs._(this);
Timeouts get timeouts => new Timeouts._(this);
diff --git a/lib/webdriver.dart b/lib/webdriver.dart
index e9a96d2..5e5f7e8 100644
--- a/lib/webdriver.dart
+++ b/lib/webdriver.dart
@@ -19,6 +19,7 @@
part 'src/exception.dart';
part 'src/keyboard.dart';
part 'src/keys.dart';
+part 'src/logs.dart';
part 'src/mouse.dart';
part 'src/navigation.dart';
part 'src/options.dart';
diff --git a/test/src/logs_test.dart b/test/src/logs_test.dart
new file mode 100644
index 0000000..7c8e9b7
--- /dev/null
+++ b/test/src/logs_test.dart
@@ -0,0 +1,28 @@
+library webdriver_test.logs;
+
+import 'package:unittest/unittest.dart';
+import 'package:webdriver/webdriver.dart';
+
+void main() {
+ group('Logs', () {
+ WebDriver driver;
+
+ setUp(() async {
+ Map capabilities = Capabilities.chrome
+ ..[Capabilities.LOGGING_PREFS] =
+ {LogType.PERFORMANCE: LogLevel.INFO};
+ driver = await WebDriver.createDriver(desiredCapabilities: capabilities);
+ await driver.get('http://www.google.com');
+ });
+
+ tearDown(() => driver.quit());
+
+ test('get logs', () async {
+ Iterable<LogEntry> logs = await driver.logs.get(LogType.PERFORMANCE);
+ expect(logs.length, greaterThan(0));
+ logs.forEach((entry) {
+ expect(entry.level, equals(LogLevel.INFO));
+ });
+ });
+ });
+}
diff --git a/test/webdriver_test.dart b/test/webdriver_test.dart
index 2e4b19f..5d479cc 100644
--- a/test/webdriver_test.dart
+++ b/test/webdriver_test.dart
@@ -4,6 +4,7 @@
import 'src/alert_test.dart' as alert;
import 'src/keyboard_test.dart' as keyboard;
+import 'src/logs_test.dart' as logs;
import 'src/mouse_test.dart' as mouse;
import 'src/navigation_test.dart' as navigation;
import 'src/options_test.dart' as options;
@@ -12,6 +13,7 @@
import 'src/web_element_test.dart' as web_element;
import 'src/window_test.dart' as window;
+
/**
* These tests are not expected to be run as part of normal automated testing,
* as they are slow and they have external dependencies.
@@ -21,6 +23,7 @@
alert.main();
keyboard.main();
+ logs.main();
mouse.main();
navigation.main();
options.main();