1

我正在使用量角器來運行端到端測試,並且在Ubuntu上的Chrome和Firefox中一切運行良好。當我嘗試使用PhantomJS運行測試時,它說它無法找到元素。我正在使用Angular v1.2.15。我的目標是在亞馬遜Linux AMI上運行測試,因此我必須讓PhantomJS工作或安裝Chrome或Firefox,這看起來很複雜。我已經讀過PhantomJS不適合在EC2實例上測試,但是我應該使用瀏覽器嗎?這是我得到的錯誤和堆棧跟蹤:如何在亞馬遜Linux AMI上運行E2E測試?

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

對不起,我不記得我最終做了什麼。 – Brendan

回答

0

我在雲中使用無頭硒服務器,它提供的Chrome &火狐甚至儘管沒有真正的DISPLAY。我剛剛在這裏移動了配置文件:https://github.com/elgalu/headless