forked from php-webdriver/php-webdriver
-
Notifications
You must be signed in to change notification settings - Fork 55
How to check javascript errors
Ildar Amankulov edited this page Apr 15, 2016
·
1 revision
variant 1)
$has_js_errors = $session->execute(array('script' => 'return $("body").attr("JSError") != undefined', 'args' => array()));
variant 2)
--- a/php-webdriver/PHPWebDriver/WebDriverSession.php
+++ b/php-webdriver/PHPWebDriver/WebDriverSession.php
@@ -46,6 +46,7 @@ class PHPWebDriver_WebDriverSession extends PHPWebDriver_WebDriverContainer {
'doubleclick' => 'POST',
'location' => array('GET', 'POST'),
'file' => 'POST',
+ 'log' => 'POST',
);
}
....
$session = $web_driver->session('chrome', array('loggingPrefs'=>array('browser'=>'ALL')));
.....
$has_js_errors_in_console = $session->log(array('type'=>'browser'));
$has_js_errors_in_console = array_filter($log, function($v) {return !in_array($v['level'], array('INFO','WARNING'));});