nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.79k stars 1.31k forks source link

acceptSslCerts for PhantomJS not working properly #582

Closed Sniperfairy closed 9 years ago

Sniperfairy commented 9 years ago

The localhost that my company uses has a https://localhost: ### url. When running through Google Chrome or Mozilla Firefox, the "acceptSslCerts" : true works properly and automatically proceeds to the expected page.

For PhantomJS, this is not the case. In my test document, the first instruction is client.insert.title('Title'). Upon running this test, I kept receiving a failed test result that read "Testing if the page title equals "Title".: Expected "Title" but got: """. This indicated that the test was not going to the proper page when running through nightwatch-phantomjs. I tried registering phantomjs through the Selenium Grid for GhostDriver, attempted different setting in the nightwatch.json file, and rewrote tests that relied not on imagery but on the HTML codes, such as looking for titles or words.

A co-worker and I figured out that the ssl warning page actually doesn't have properties like a title and came to the conclusion that the acceptSslCerts actually do not work in phantomjs. We could not find documentation anywhere to fix this issue, which is why I am reporting it here. To verify this, we changed all of our urls to http://localhost:####, after which, the tests started to pass again. Currently, we are trying to figure out a way to work around this without having to purchase a ssl certificate.

If there is anymore information I can provide or if there is a solution that I am missing, please let me know. This is the first time I am submitting an issue through GitHub and there might be different policies that I am unaware of. Really, I posted this as a means to help another user in the future if they come across this problem.

Attached, I have my nightwatch.json file that may help as a reference.

sknopf commented 9 years ago

Yeah that's an issue with the GhostDriver - try adding to your desiredCapabilities “phantomjs.cli.args”: [“—ignore-ssl-errors=true”]

Sniperfairy commented 9 years ago

We tried that as well but it did not work properly either.

Sniperfairy commented 9 years ago

For that command to work, does the selenium grid have to be running?

sharadJay commented 9 years ago

I am also facing same issue at the moment. I am passing cli argument like this:-

"phantomjs.cli.args": "--acceptSslCerts=true --web-security=no --ignore-ssl-errors=yes --ssl-protocol=any --webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444"

but I see ,"acceptSslCerts":false in negotiated capabilities:-

CONSTRUCTOR - Desired Capabilities: {"acceptSslCerts":true,"phantomjs.binary.path":"node_modules/resources/phantomjs/bin/phantomjs","name":"Sample Test","browserName":"phantomjs","javascriptEnabled":true,"phantomjs.cli.args":"--acceptSslCerts=true --web-security=no --ignore-ssl-errors=yes --ssl-protocol=any --webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444","platform":"ANY"}
CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":"1.9.2","driverName":"ghostdriver","driverVersion":"1.0.4","platform":"mac-unknown-32bit","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"}}'

Did any one solve this issue?

sknopf commented 9 years ago

I was able to get it working with how I specified above (note the array). You may also try upgrading your phantomjs version to 2.0.

One other thing - I'm not sure the logging was ever correct coming from ghostdriver (I am not currently at my computer to check). I suggest adding a simple UI test like checking for a the existence of element to see if it worked.

On Aug 13, 2015, at 4:27 AM, sharad jain notifications@github.com wrote:

I am also facing same issue at the moment. I am passing cli argument like this:-

"phantomjs.cli.args": "--acceptSslCerts=true --web-security=no --ignore-ssl-errors=yes --ssl-protocol=any --webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444" but I see ,"acceptSslCerts":false in negotiated capabilities:-

CONSTRUCTOR - Desired Capabilities: {"acceptSslCerts":true,"phantomjs.binary.path":"node_modules/resources/phantomjs/bin/phantomjs","name":"Sample Test","browserName":"phantomjs","javascriptEnabled":true,"phantomjs.cli.args":"--acceptSslCerts=true --web-security=no --ignore-ssl-errors=yes --ssl-protocol=any --webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444","platform":"ANY"} CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":"1.9.2","driverName":"ghostdriver","driverVersion":"1.0.4","platform":"mac-unknown-32bit","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"}}' Did any one solve this issue?

— Reply to this email directly or view it on GitHub.

Sniperfairy commented 9 years ago

Thank you very much!  From: Stephanie Madison notifications@github.com To: nightwatchjs/nightwatch nightwatch@noreply.github.com Cc: Sniperfairy samantha.stachowiak@yahoo.com Sent: Thursday, August 13, 2015 9:22 AM Subject: Re: [nightwatch] acceptSslCerts for PhantomJS not working properly (#582)

I was able to get it working with how I specified above (note the array). You may also try upgrading your phantomjs version to 2.0.

One other thing - I'm not sure the logging was ever correct coming from ghostdriver (I am not currently at my computer to check). I suggest adding a simple UI test like checking for a the existence of element to see if it worked.

On Aug 13, 2015, at 4:27 AM, sharad jain notifications@github.com wrote:

I am also facing same issue at the moment. I am passing cli argument like this:-

"phantomjs.cli.args": "--acceptSslCerts=true --web-security=no --ignore-ssl-errors=yes --ssl-protocol=any --webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444" but I see ,"acceptSslCerts":false in negotiated capabilities:-

CONSTRUCTOR - Desired Capabilities: {"acceptSslCerts":true,"phantomjs.binary.path":"node_modules/resources/phantomjs/bin/phantomjs","name":"Sample Test","browserName":"phantomjs","javascriptEnabled":true,"phantomjs.cli.args":"--acceptSslCerts=true --web-security=no --ignore-ssl-errors=yes --ssl-protocol=any --webdriver=5558 --webdriver-selenium-grid-hub=http://localhost:4444","platform":"ANY"} CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":"1.9.2","driverName":"ghostdriver","driverVersion":"1.0.4","platform":"mac-unknown-32bit","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"}}' Did any one solve this issue?

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub.

sknopf commented 9 years ago

Sounds like this is resolved, so closing this out.

Sniperfairy commented 8 years ago

Just to give an update to anybody that is looking to resolve the issue:

  1. remove acceptSslCerts completely from the desired capabilities
  2. replace with "phantomjs.cli.args": ["--ignore-ssl-errors=true", "--web-security=false"]

This is a phantomjs configuration issue. Sorry for replaying so late.

ManojTestAuto commented 7 years ago

Hi All, I am getting below error when i try to handle an element using phantom js in C#


Result Message: OpenQA.Selenium.NoSuchElementException : {"errorMessage":"Unable to find element with id 'testid1'","request":{"headers":{"Accept":"application/json, image/png","Connection":"Close","Content-Length":"31","Content-Type":"application/json;charset=utf-8","Host":"localhost:54650"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"menuDD\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/289b2f60-c2ca-11e6-bb28-53c37fb249a1/element"}}

Please help me in this

Thanks Manu