我正在使用Protractor来运行端到端测试,并且在Ubuntu上Chrome和Firefox中的一切运行良好。当我尝试使用PhantomJS运行测试时,它说它无法找到元素。我正在使用Angular v1.2.15。我的目标是在Amazon Linux AMI上运行测试,因此我要么让PhantomJS工作,要么安装Chrome或Firefox,这看起来非常复杂。我已经读过PhantomJS不适合在EC2实例上进行测试,但是我应该使用一个浏览器吗?这是我得到的错误和堆栈跟踪:
UnknownError: {"errorMessage":"Unable to find element with id 'username'","request": {"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content- Length":"33","Content-Type":"application/json; charset=utf- 8","Host":"localhost:28418"},"httpVersion":"1.1","method":"POST","post":" {\"using\":\"id\",\"value\":\"username\"}","url":"/element","urlParsed": {"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/elem ent","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"", "source":"/element","queryKey":{},"chunks": ["element"]},"urlOriginal":"/session/7e7e8860-cb0a-11e3-b0d0-117406720391/element"}}
Build info: version: '2.40.0', revision: 'fbe29a9', time: '2014-02-19 20:54:28'
System info: host: 'Brendan-Kirby-BN', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.11.0-18-generic', java.version: '1.7.0_51'
Driver info: driver.version: unknown
Stacktrace:
Error
at null.<anonymous> (/home/brendankirby/ads/apps/client/test/ads-login-spec.js:4:3)
at Object.<anonymous> (/home/brendankirby/ads/apps/client/test/ads-login-spec.js:3:1)
At async task:
UnknownError: {"errorMessage":"Unable to find element with id 'username'","request":{"headers":{"Accept":"application/json, image/png","Connection":"Keep- Alive","Content-Length":"33","Content-Type":"application/json; charset=utf- 8","Host":"localhost:28418"},"httpVersion":"1.1","method":"POST","post":" {\"using\":\"id\",\"value\":\"username\"}","url":"/element","urlParsed": {"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/elem ent","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"", "source":"/element","queryKey":{},"chunks": ["element"]},"urlOriginal":"/session/7e7e8860-cb0a-11e3-b0d0-117406720391/element"}}
Build info: version: '2.40.0', revision: 'fbe29a9', time: '2014-02-19 20:54:28'
System info: host: 'Brendan-Kirby-BN', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.11.0-18-generic', java.version: '1.7.0_51'
Driver info: driver.version: unknown
==== async task ====
WebDriver.findElement(By.id("username"))
at Protractor.findElement (/usr/lib/node_modules/protractor/lib/protractor.js:748:25)
at Object.elementFinder.(anonymous function) [as sendKeys] (/usr/lib/node_modules/protractor/lib/protractor.js:103:24)
at null.<anonymous> (/home/brendankirby/ads/apps/client/test/ads-login-spec.js:9:32)
这是phantomjs日志:
[INFO - 2014-04-23T17:12:47.902Z] GhostDriver - Main - running on port 28418
[INFO - 2014-04-23T17:12:48.363Z] Session [7e7e8860-cb0a-11e3-b0d0-117406720391] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true ,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent ":"Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.7 Safari/534.34","webSecurityEnabled":true}
[INFO - 2014-04-23T17:12:48.363Z] Session [7e7e8860-cb0a-11e3-b0d0-117406720391] - page.customHeaders: - {}
[INFO - 2014-04-23T17:12:48.363Z] Session [7e7e8860-cb0a-11e3-b0d0-117406720391] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"1.9.7","driverName":"ghostdriver","driverVersion":"1.1 .0","platform":"linux-unknown- 64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnable d":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEn abled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptS slCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO - 2014-04-23T17:12:48.364Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 7e7e8860-cb0a-11e3-b0d0-117406720391
[ERROR - 2014-04-23T17:12:50.308Z] Session [7e7e8860-cb0a-11e3-b0d0-117406720391] - page.onError - msg: SyntaxError: Parse error
[ERROR - 2014-04-23T17:12:50.308Z] Session [7e7e8860-cb0a-11e3-b0d0-117406720391] - page.onError - stack:
[ERROR - 2014-04-23T17:12:50.314Z] Session [7e7e8860-cb0a-11e3-b0d0-117406720391] - page.onError - msg: ReferenceError: Can't find variable: angular
[ERROR - 2014-04-23T17:12:50.314Z] Session [7e7e8860-cb0a-11e3-b0d0-117406720391] - page.onError - stack:
(anonymous function) (http://ads-qa.bnservers.com/scripts/a267e5f1.scripts.js:1)
[ERROR - 2014-04-23T17:12:50.686Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1398273170644
[INFO - 2014-04-23T17:12:52.211Z] ShutdownReqHand - _handle - About to shutdown
答案 0 :(得分:0)
我在云中使用无头硒服务器,它提供Chrome&amp; Firefox虽然没有真正的DISPLAY。我刚刚在这里移动了配置文件:https://github.com/elgalu/headless