Javascript 使用phantomjs驱动程序时未获取浏览器日志

Javascript 使用phantomjs驱动程序时未获取浏览器日志,javascript,selenium,logging,phantomjs,ghostdriver,Javascript,Selenium,Logging,Phantomjs,Ghostdriver,在Selenium测试用例中,我添加了一个特殊的断言,以确保测试中的代码不会在浏览器控制台中生成错误。 为了实现这一点,我将捕获浏览器日志,并查看是否有任何日志条目的日志级别>信息 在运行selenium测试时,我可以使用Chrome或Firefox获取浏览器日志,测试配置如下(下面是PhantomJS的示例): 但是,当使用PhantomJS时,我不会得到任何日志,即以下表达式返回0: driver.manage().logs().get(LogType.BROWSER).getAll().s

在Selenium测试用例中,我添加了一个特殊的断言,以确保测试中的代码不会在浏览器控制台中生成错误。 为了实现这一点,我将捕获浏览器日志,并查看是否有任何日志条目的日志级别>信息

在运行selenium测试时,我可以使用Chrome或Firefox获取浏览器日志,测试配置如下(下面是PhantomJS的示例):

但是,当使用PhantomJS时,我不会得到任何日志,即以下表达式返回0:

driver.manage().logs().get(LogType.BROWSER).getAll().size()
配置:

  • 硒:2.45.0
  • 幻影JS:1.9.8
  • 操作系统:mac-10.10(约塞米蒂)-32位
  • phantomjs驱动程序:1.2.1(使用“com.codeborne”%“phantomjsdriver”%“1.2.1”)
  • ghostdriver 1.1.0
查询可用日志类型时,通过:

driver.manage().logs().getAvailableLogTypes()
我得到:[har,browser,client],'har'和'client'确实有get日志条目

下面是执行测试时的输出。您会注意到确实有一些page.onError(我正试图通过日志捕获的内容),它们应该是捕获的浏览器日志的一部分

你能看到驱动程序的设置有什么问题吗

看看单元测试:,它应该可以工作,所以我的设置(代码或库)中一定有错误,但我无法发现它

谢谢


2015年4月29日下午1:24:35 org.openqa.selenium.phantomjs.PhantomJSDriverService
信息:可执行文件:/tmp/phantomjs-1.9.8-macosx/bin/phantomjs
2015年4月29日下午1:24:35 org.openqa.selenium.phantomjs.PhantomJSDriverService
信息:端口:8208
2015年4月29日下午1:24:35 org.openqa.selenium.phantomjs.PhantomJSDriverService
信息:参数:[--webdriver=8208,--webdriver日志文件=/tmp/phantomjsdriver.log]
2015年4月29日下午1:24:35 org.openqa.selenium.phantomjs.PhantomJSDriverService
信息:环境:{}
PhantomJS正在启动GhostDriver。。。
[信息-2015-04-29T11:24:36.729Z]幽灵驱动程序-主-在端口8208上运行
[INFO-2015-04-29T11:24:37.222Z]会话[51a8f330-ee62-11e4-b50f-c5e60b20f37e]-page.settings-{“xsauditingEnabled”:false,“javascriptCanCloseWindows”:true,“javascriptCanOpenWindows”:true,“javascriptEnabled”:true,“localToRemoteUrlAccessEnabled”:false,“userAgent”:“Mozilla/5.0(Macintosh;Intel Mac OS X)AppleWebKit/534.34(KHTML,像壁虎一样)PhantomJS/1.9.8safari/534.34,“webSecurityEnabled”:true}
[INFO-2015-04-29T11:24:37.222Z]会话[51a8f330-ee62-11e4-b50f-c5e60b20f37e]-第页。自定义标题:-{}
[信息-2015-04-29T11:24:37.222Z]会话[51a8f330-ee62-11e4-b50f-c5e60b20f37e]-会话协商能力-{“浏览器名”:“幻影”,“版本”:“1.9.8”,“驱动程序名”:“幻影驱动程序”,“驱动程序版本”:“1.1.0”,“平台”:“mac-10.10(约塞米蒂)”-32位”,“javascriptEnabled”:真,“TakesScreensshot”:真,“handlesAlerts”:假,“databaseEnabled”:假,“locationContextEnabled”:false,“applicationCacheEnabled”:false,“browserConnectionEnabled”:false,“CSSSelectorEnabled”:true,“WebStorage Enabled”:false,“rotatable”:false,“acceptSslCerts”:false,“nativeEvents”:true,“proxy”:“direct”}
[信息-2015-04-29T11:24:37.222Z]会话管理器RQHAND-_PostNewsSession命令-创建的新会话:51a8f330-ee62-11e4-b50f-c5e60b20f37e
使用org.openqa.selenium.phantomjs.PhantomJSDriver运行selenium
[信息]应用程序-本地主机上的ElasticSearch:9300
[ERROR-2015-04-29T11:24:39.523Z]会话[51a8f330-ee62-11e4-b50f-c5e60b20f37e]-page.onError-msg:ERROR:[$rootScope:infdig]10$digest()已达到迭代次数。正在中止!
在过去5次迭代中激发的观察者:[]
http://errors.angularjs.org/1.3.15/$rootScope/infdig?p0=10&p1=%5B%5D
[错误-2015-04-29T11:24:39.523Z]会话[51a8f330-ee62-11e4-b50f-c5e60b20f37e]-第页错误-堆栈:
(匿名函数)(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:26446)
(匿名函数)(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:26668)
自举(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:13555)
援引(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:16300)
(匿名函数)(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:13556)
引导(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:13570)
角闪石(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:13464)
(匿名函数)(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:38401)
(匿名函数)(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:3048)
(匿名函数)(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:3160)
(匿名函数)(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:433)
(匿名函数)(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:104)
[ERROR-2015-04-29T11:24:39.535Z]会话[51a8f330-ee62-11e4-b50f-c5e60b20f37e]-page.onError-msg:ERROR:[$rootScope:infdig]10$digest()已达到迭代次数。正在中止!
在过去5次迭代中激发的观察者:[]
http://errors.angularjs.org/1.3.15/$rootScope/infdig?p0=10&p1=%5B%5D
[错误-2015-04-29T11:24:39.535Z]会话[51a8f330-ee62-11e4-b50f-c5e60b20f37e]-第页错误-堆栈:
(匿名函数)(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:26446)
(匿名函数)(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:26668)
完成(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:21795)
完成任务(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:21985)
请求加载(http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:21930)
[ERROR-2015-04-29T11:24:39.551Z]会话[51a8f330-ee62-11e4-b50f-c5e60b20f37e]-page.onError-msg:ERROR:[$rootScope:infdig]10$digest()已达到迭代次数。正在中止!
在过去5次迭代中激发的观察者:[]
http://errors.angularjs.org/1.3.15/$rootScope/infdig?p0=10&p1=%5B%5D
[错误-2015-04-29T11:24:39.551Z]会话[51a8f330-ee62-11e4-b50f-c5e60b20f37e]-第页
driver.manage().logs().getAvailableLogTypes()
Apr 30, 2015 12:39:14 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: executable: <...>/Documents/phantomjs-2.0/phantomjs
Apr 30, 2015 12:39:14 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: port: 42987
Apr 30, 2015 12:39:14 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: arguments: [--webdriver=42987, --webdriver-logfile=<...>/phantomjsdriver.log]
Apr 30, 2015 12:39:14 PM org.openqa.selenium.phantomjs.PhantomJSDriverService <init>
INFO: environment: {}
[INFO  - 2015-04-30T10:39:15.103Z] GhostDriver - Main - running on port 42987
[INFO  - 2015-04-30T10:39:15.468Z] Session [25c7d880-ef25-11e4-a0e9-4d6ab124ffa3] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.0.0 Safari/538.1","webSecurityEnabled":true}
[INFO  - 2015-04-30T10:39:15.468Z] Session [25c7d880-ef25-11e4-a0e9-4d6ab124ffa3] - page.customHeaders:  - {}
[INFO  - 2015-04-30T10:39:15.468Z] Session [25c7d880-ef25-11e4-a0e9-4d6ab124ffa3] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"2.0.0","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"mac-10.9 (Mavericks)-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO  - 2015-04-30T10:39:15.468Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 25c7d880-ef25-11e4-a0e9-4d6ab124ffa3
Running selenium with org.openqa.selenium.phantomjs.PhantomJSDriver
[info] application - ElasticSearch at localhost:9300
[ERROR - 2015-04-30T10:39:18.825Z] Session [25c7d880-ef25-11e4-a0e9-4d6ab124ffa3] - page.onError - msg: Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.15/$rootScope/infdig?p0=10&p1=%5B%5D
    at $digest (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:26446:31)
    at $apply (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:26668:31)
    at bootstrapApply (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:13552:21)
    at invoke (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:16300:22)
    at doBootstrap (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:13550:20)
    at bootstrap (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:13570:23)
    at angularInit (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:13464:14)
    at http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:38401:16
    at fire (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:3048:35)
    at fireWith (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:3160:11)
    at ready (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:433:24)
    at completed (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:104:16)

  :262 in error
[ERROR - 2015-04-30T10:39:18.825Z] Session [25c7d880-ef25-11e4-a0e9-4d6ab124ffa3] - page.onError - stack:
  (anonymous function) (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:23752)

  :262 in error
[ERROR - 2015-04-30T10:39:18.832Z] Session [25c7d880-ef25-11e4-a0e9-4d6ab124ffa3] - page.onError - msg: Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.15/$rootScope/infdig?p0=10&p1=%5B%5D
    at $digest (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:26446:31)
    at $apply (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:26668:31)
    at done (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:21795:53)
    at completeRequest (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:21985:15)
    at requestLoaded (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:21926:24)

  :262 in error
[ERROR - 2015-04-30T10:39:18.832Z] Session [25c7d880-ef25-11e4-a0e9-4d6ab124ffa3] - page.onError - stack:
  (anonymous function) (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:23752)

  :262 in error
[ERROR - 2015-04-30T10:39:18.839Z] Session [25c7d880-ef25-11e4-a0e9-4d6ab124ffa3] - page.onError - msg: Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: []
http://errors.angularjs.org/1.3.15/$rootScope/infdig?p0=10&p1=%5B%5D
    at $digest (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:26446:31)
    at $apply (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:26668:31)
    at done (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:21795:53)
    at completeRequest (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:21985:15)
    at requestLoaded (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:21926:24)

  :262 in error
[ERROR - 2015-04-30T10:39:18.839Z] Session [25c7d880-ef25-11e4-a0e9-4d6ab124ffa3] - page.onError - stack:
  (anonymous function) (http://localhost:3333/assets/bundles/js/vendor-6fac01f5.js:23752)

  :262 in error
--------------- 0
[INFO  - 2015-04-30T10:39:19.105Z] ShutdownReqHand - _handle - About to shutdown