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

Screenshots not working on phantomJS #251

Closed ozymandias547 closed 10 years ago

ozymandias547 commented 10 years ago

We are using the following phantomJS configuration:

"desiredCapabilities" : { 
        "browserName": "phantomjs",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
        "phantomjs.cli.args" : ["--ignore-ssl-errors=true"],
        "phantomjs.binary.path": require("phantomjs").path
}

The screenshots taken by the saveScreenShot(...) command are just coming back with basically print screens of the desktop. I'm not sure if this is an issue or a feature request, either way it would be nice to have the screenshots.

thanks for the time! this project is being used extensively.

beatfactor commented 10 years ago

My pleasure. Isn't this an issue with the ghostdriver (phantomjs selenium webdriver implementaiton)?

rcherny commented 10 years ago

Hey @beatfactor, @ozymandias547 and I work together.

This is the most current ticket I can see that might be the cause of this:

https://github.com/detro/ghostdriver/issues/360

Not even sure I follow it but we'll dig and see if we can identify the issue.

What we forgot to mention was that the issue seems to surface more when errors happen and Nightwatch is to save a screenshot for the JUnit XML reports and the screenshot is not returned or not correctly returned. We effectively get an empty PNG file, and the selenium log has:

Error communicating with the remote browser. It may have died

Which is a known PhantomJS issue (I'll have to dig for the ticket).

rcherny commented 10 years ago

Here's the ticket:

https://github.com/detro/ghostdriver/issues/140

Seems to happen in our case more often than not when we've resized the browser window (such as it is, with PhantomJS).

rcherny commented 10 years ago

Speaking with @ozymandias547 and running more tests, we think we have two distinct issues. We do in fact get "Print Screen" images from PhantomJS (or any browser) when Errors are fired.

beatfactor commented 10 years ago

The print screen images are just received as part of the error message from selenium so nightwatch saves them if desired. They are not useful in the case of PhantomJS but this is not an issue with the current nightwatch implementation.

rcherny commented 10 years ago

Hey @beatfactor we've isolated the bigger issue at the moment. We'll look into PhantomJS / Selenium / Ghostdriver and see if we can find the issue with screenshots on errors.

We'll open another ticket which has to do with what Nightwatch does when the browser (in this case Phantom) crashes, mid-test. It fails with assertions failing everywhere -- at the least it'd be nice if it understood the difference.

Thanks again!

ozymandias547 commented 10 years ago

Closing until we find more information that can help Nightwatch. This seems to be an issue with phantomJS and Selenium instead for now.

GrayedFox commented 8 years ago

@rcherny sorry to sort of hijack this thread - but you mentioned you resized the browser window of PhantomJS? How did you do that?

browser.maximizeWindow(); works for some browsers (FF but not Chrome, on my machine) and it doesn't seem to work for PhantomJS. I'm pretty sure I'm having the issue reported here (except I'm using Nightwatch and not Protractor), as our website design is reactive and thus a smaller viewport / window size means differently named / located elements.

Feel free to PM me! Twitter tag

vangorra commented 7 years ago

I've been investigating this a bit. When calling this.saveScreenshot, a screenshot of the browser is appearing properly. When an assertion fails however, the entire desktop is appearing. It looks like code that gets a screenshot when an assertion fails is here https://github.com/nightwatchjs/nightwatch/blob/master/lib/index.js#L384-L393.

You will notice that it is receiving a screenshot directly from phantom. Presumably, phantomjs should be providing a correct screenshot when the error is triggered.

Questions: