Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

PhantomJS Issues #58

Open
maureeno20 opened this issue May 7, 2016 · 9 comments
Open

PhantomJS Issues #58

maureeno20 opened this issue May 7, 2016 · 9 comments
Assignees

Comments

@maureeno20
Copy link

I get the following error when trying to run the tests:

Command failed: /usr/local/lib/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /usr/local/lib/node_modules/a11y/audits.js {"delay":1,"url":"http://bbc.co.uk","width":1024,"height":768} --ignore-ssl-errors=true --ssl-protocol=tlsv1 --local-to-remote-url-access=true
Audit failed

I got a similar error on initial install so I manually installed PhantomJS but still can't get any test to work.

@rickydazla
Copy link

Same here

1 similar comment
@sjurlur
Copy link

sjurlur commented Jun 13, 2016

Same here

@addyosmani
Copy link
Owner

Can you confirm what version of PhantomJS you have locally installed?

@addyosmani addyosmani self-assigned this Jun 13, 2016
@rickydazla
Copy link

1.9.1.7

@sjurlur
Copy link

sjurlur commented Jun 13, 2016

npm ls phantomjs
a11y@0.4.1 /usr/local/lib/node_modules/a11y
└── phantomjs@2.1.7

@jatinsi
Copy link

jatinsi commented Jul 6, 2016

Try uninstalling phantomjs and a11y and reinstalling only a11y.

npm uninstall a11y --global
npm uninstall phantomjs --global

npm install --global a11y

I fixed the same issue on my machine using the above step.

@agarzola
Copy link

I’m getting this same error when trying to run a11y on certain websites, but not all. I’ve yet to find a definitive factor that predictably determines whether a11ying a site will result in this error or not. I do know that the sites where it does fail, it does so consistently.

http://bbc.co.uk, as reported by @maureeno20, gets the error. So does http://asmallbatch.co. Both of those locations have redirects, but so does http://mrkp.co and that one loads fine.

Reinstalling a11y globally does not seem to have an effect, in my case. The only version of phantomjs I have installed (globally, anyway) is the one installed as a dependency of a11y:

$ npm ls --global phantomjs
/Users/agarzola/.nvm/versions/node/v4.2.4/lib
└─┬ a11y@0.4.1
  └── phantomjs@2.1.7

@jonnyi
Copy link

jonnyi commented Feb 3, 2017

@agarzola Seeing the exact same issues even following the reinstallation step for a11y and phantomjs.

@bennypowers
Copy link

bennypowers commented Mar 7, 2017

When I ran the command that a11y generates, I got a bit more info on what was going wrong:

/Users/bennyp/.config/yarn/global/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs /Users/bennyp/.config/yarn/global/node_modules/a11y/audits.js {"delay":1,"url":"http://mrkp.co","width":1024,"height":768} --ignore-ssl-errors=true --ssl-protocol=tlsv1 --local-to-remote-url-access=true
SyntaxError: JSON Parse error: Unexpected identifier "delay"

  phantomjs://code/audits.js:11 in parse

So here's some more verbose debugging info:

/Users/bennyp/.config/yarn/global/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs --debug=true /Users/bennyp/.config/yarn/global/node_modules/a11y/audits.js {"url":"http://mrkp.co","width":1024,"height":768} --ignore-ssl-errors=true --ssl-protocol=tlsv1 --local-to-remote-url-access=true 
2017-03-07T15:16:15 [DEBUG] CookieJar - Created but will not store cookies (use option '--cookies-file=<filename>' to enable persistent cookie storage)
2017-03-07T15:16:15 [DEBUG] Set  "http"  proxy to:  "" : 1080
2017-03-07T15:16:15 [DEBUG] Phantom - execute: Configuration
2017-03-07T15:16:15 [DEBUG]      0 objectName : ""
2017-03-07T15:16:15 [DEBUG]      1 cookiesFile : ""
2017-03-07T15:16:15 [DEBUG]      2 diskCacheEnabled : "false"
2017-03-07T15:16:15 [DEBUG]      3 maxDiskCacheSize : "-1"
2017-03-07T15:16:15 [DEBUG]      4 diskCachePath : ""
2017-03-07T15:16:15 [DEBUG]      5 ignoreSslErrors : "false"
2017-03-07T15:16:15 [DEBUG]      6 localUrlAccessEnabled : "true"
2017-03-07T15:16:15 [DEBUG]      7 localToRemoteUrlAccessEnabled : "false"
2017-03-07T15:16:15 [DEBUG]      8 outputEncoding : "UTF-8"
2017-03-07T15:16:15 [DEBUG]      9 proxyType : "http"
2017-03-07T15:16:15 [DEBUG]      10 proxy : ":1080"
2017-03-07T15:16:15 [DEBUG]      11 proxyAuth : ":"
2017-03-07T15:16:15 [DEBUG]      12 scriptEncoding : "UTF-8"
2017-03-07T15:16:15 [DEBUG]      13 webSecurityEnabled : "true"
2017-03-07T15:16:15 [DEBUG]      14 offlineStoragePath : ""
2017-03-07T15:16:15 [DEBUG]      15 localStoragePath : ""
2017-03-07T15:16:15 [DEBUG]      16 localStorageDefaultQuota : "-1"
2017-03-07T15:16:15 [DEBUG]      17 offlineStorageDefaultQuota : "-1"
2017-03-07T15:16:15 [DEBUG]      18 printDebugMessages : "true"
2017-03-07T15:16:15 [DEBUG]      19 javascriptCanOpenWindows : "true"
2017-03-07T15:16:15 [DEBUG]      20 javascriptCanCloseWindows : "true"
2017-03-07T15:16:15 [DEBUG]      21 sslProtocol : "default"
2017-03-07T15:16:15 [DEBUG]      22 sslCiphers : "blahblah"
2017-03-07T15:16:15 [DEBUG]      23 sslCertificatesPath : ""
2017-03-07T15:16:15 [DEBUG]      24 sslClientCertificateFile : ""
2017-03-07T15:16:15 [DEBUG]      25 sslClientKeyFile : ""
2017-03-07T15:16:15 [DEBUG]      26 sslClientKeyPassphrase : ""
2017-03-07T15:16:15 [DEBUG]      27 webdriver : ":"
2017-03-07T15:16:15 [DEBUG]      28 webdriverLogFile : ""
2017-03-07T15:16:15 [DEBUG]      29 webdriverLogLevel : "INFO"
2017-03-07T15:16:15 [DEBUG]      30 webdriverSeleniumGridHub : ""
2017-03-07T15:16:15 [DEBUG] Phantom - execute: Script & Arguments
2017-03-07T15:16:15 [DEBUG]      script: "/Users/bennyp/.config/yarn/global/node_modules/a11y/audits.js"
2017-03-07T15:16:15 [DEBUG]      0 arg: "url:http://mrkp.co"
2017-03-07T15:16:15 [DEBUG]      1 arg: "width:1024"
2017-03-07T15:16:15 [DEBUG]      2 arg: "height:768"
2017-03-07T15:16:15 [DEBUG]      3 arg: "--ignore-ssl-errors=true"
2017-03-07T15:16:15 [DEBUG]      4 arg: "--ssl-protocol=tlsv1"
2017-03-07T15:16:15 [DEBUG]      5 arg: "--local-to-remote-url-access=true"
2017-03-07T15:16:15 [DEBUG] Phantom - execute: Starting normal mode
2017-03-07T15:16:15 [DEBUG] WebPage - setupFrame ""
2017-03-07T15:16:15 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-03-07T15:16:15 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-03-07T15:16:15 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
SyntaxError: JSON Parse error: Unexpected identifier "url"

  phantomjs://code/audits.js:11 in parse


Hey! Look at that! that JSON string is being interpreted as an array of arguments. Let's wrap it in a single quote:

/Users/bennyp/.config/yarn/global/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs --debug=true /Users/bennyp/.config/yarn/global/node_modules/a11y/audits.js '{"url":"http://mrkp.co","width":1024,"height":768}' --ignore-ssl-errors=true --ssl-protocol=tlsv1 --local-to-remote-url-access=true 
...
2017-03-07T15:19:10 [DEBUG] Phantom - execute: Script & Arguments
2017-03-07T15:19:10 [DEBUG]      script: "/Users/bennyp/.config/yarn/global/node_modules/a11y/audits.js"
2017-03-07T15:19:10 [DEBUG]      0 arg: "{\"url\":\"http://mrkp.co\",\"width\":1024,\"height\":768}"
2017-03-07T15:19:10 [DEBUG]      1 arg: "--ignore-ssl-errors=true"
2017-03-07T15:19:10 [DEBUG]      2 arg: "--ssl-protocol=tlsv1"
2017-03-07T15:19:10 [DEBUG]      3 arg: "--local-to-remote-url-access=true"
2017-03-07T15:19:10 [DEBUG] Phantom - execute: Starting normal mode
2017-03-07T15:19:10 [DEBUG] WebPage - setupFrame ""
2017-03-07T15:19:10 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-03-07T15:19:10 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-03-07T15:19:10 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
2017-03-07T15:19:10 [DEBUG] WebPage - updateLoadingProgress: 10
...
2017-03-07T15:19:17 [DEBUG] WebPage - updateLoadingProgress: 47
2017-03-07T15:19:17 [DEBUG] WebPage - setupFrame ""
2017-03-07T15:19:17 [WARNING] Can't open 'node_modules/phantomjs-polyfill/bind-polyfill.js'
2017-03-07T15:19:18 [DEBUG] WebPage - updateLoadingProgress: 48
...
2017-03-07T15:19:19 [DEBUG] WebPage - updateLoadingProgress: 72
2017-03-07T15:19:19 [DEBUG] CookieJar - Saved "_ga=GA1.2.363466829.1488892759; expires=Thu, 07-Mar-2019 13:19:19 GMT; domain=.mrkp.co; path=/"
2017-03-07T15:19:19 [DEBUG] CookieJar - Saved "_ga=GA1.2.363466829.1488892759; expires=Thu, 07-Mar-2019 13:19:19 GMT; domain=.mrkp.co; path=/"
2017-03-07T15:19:19 [DEBUG] CookieJar - Saved "_gat=1; expires=Tue, 07-Mar-2017 13:20:19 GMT; domain=.mrkp.co; path=/"
2017-03-07T15:19:19 [DEBUG] WebPage - updateLoadingProgress: 74
...
2017-03-07T15:19:22 [DEBUG] WebPage - updateLoadingProgress: 100
2017-03-07T15:19:22 [WARNING] Can't open 'node_modules/accessibility-developer-tools/dist/js/axs_testing.js'
2017-03-07T15:19:22 [DEBUG] WebPage - setupFrame ""
2017-03-07T15:19:22 [DEBUG] WebPage - evaluateJavaScript "(function() { return (function () {\n            var results = axs.Audit.run();\n\n            var audit = results.map(function (result) {\n                var DOMElements = result.elements;\n                var message = '';\n\n                if (DOMElements !== undefined) {\n                    for (var i = 0; i < DOMElements.length; i++) {\n                        var el = DOMElements[i];\n                        message += '\\n';\n                        // Get query selector not browser independent. catch any errors and\n                        // default to simple tagName.\n                        try {\n                            message += axs.utils.getQuerySelectorText(el);\n                        } catch (err) {\n                            message += ' tagName:' + el.tagName;\n                            message += ' id:' + el.id;\n                        }\n                    }\n                }\n\n                return {\n                    code: result.rule.code,\n                    heading: result.rule.heading,\n                    result: result.result,\n                    severity: result.rule.severity,\n                    url: result.rule.url,\n                    elements: message\n                };\n            });\n\n            return {\n                audit: audit,\n                report: axs.Audit.createReport(results)\n            };\n        })(); })()"
2017-03-07T15:19:22 [DEBUG] WebPage - evaluateJavaScript result QVariant(Invalid)
Audit failed
2017-03-07T15:19:22 [DEBUG] WebPage - setupFrame ""
2017-03-07T15:19:22 [WARNING] Can't open 'node_modules/phantomjs-polyfill/bind-polyfill.js'
2017-03-07T15:19:22 [DEBUG] WebPage - updateLoadingProgress: 10
2017-03-07T15:19:22 [DEBUG] WebPage - setupFrame ""
2017-03-07T15:19:22 [WARNING] Can't open 'node_modules/phantomjs-polyfill/bind-polyfill.js'
2017-03-07T15:19:22 [DEBUG] WebPage - updateLoadingProgress: 100
2017-03-07T15:19:22 [DEBUG] WebPage - setupFrame ""
2017-03-07T15:19:22 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-03-07T15:19:22 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-03-07T15:19:22 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
2017-03-07T15:19:22 [DEBUG] WebPage - updateLoadingProgress: 10
2017-03-07T15:19:22 [DEBUG] WebPage - setupFrame ""
2017-03-07T15:19:22 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2017-03-07T15:19:22 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2017-03-07T15:19:22 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
2017-03-07T15:19:22 [DEBUG] WebPage - updateLoadingProgress: 100
2017-03-07T15:19:22 [DEBUG] CookieJar - Saved "_ga=GA1.2.363466829.1488892759; expires=Thu, 07-Mar-2019 13:19:19 GMT; domain=.mrkp.co; path=/"
2017-03-07T15:19:22 [DEBUG] CookieJar - Saved "_gat=1; expires=Tue, 07-Mar-2017 13:20:19 GMT; domain=.mrkp.co; path=/"

Now it looks like a dependency problem. yarn global add phantomjs-polyfill; and yarn global add accessibility-developer-tools doesn't seem to help much.

( long shot but this might also be related to ariya/phantomjs#12697 and https://github.com/addyosmani/a11y/blob/master/audits.js#L104-L109 )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants