Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot save screenshots on mobile tests #2878

Closed
hex0cter opened this issue Sep 19, 2018 · 8 comments
Closed

Cannot save screenshots on mobile tests #2878

hex0cter opened this issue Sep 19, 2018 · 8 comments
Assignees
Labels
AREA: server STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: browser natives TYPE: bug The described behavior is considered as wrong (bug).
Milestone

Comments

@hex0cter
Copy link

Are you requesting a feature or reporting a bug?

Bug

What is the current behavior?

When testing on iPhone, .takeElementScreenshot doesn't not work. Here is the error:

events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open '/Users/daniel.han/tmp/testcafe-boilerplate/duckduckgo-screenshots.png'
Emitted 'error' event at:
    at lazyFs.open (internal/fs/streams.js:115:12)
    at FSReqWrap.oncomplete (fs.js:139:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

What is the expected behavior?

Taking screenshots should work the same way as desktop browsers.

How would you reproduce the current behavior (if this is a bug)?

Run any test on iPhone 7, iOS 12 with mobile safari.

Provide the test code and the tested page URL (if applicable)

Tested page URL:
https://github.com/hex0cter/testcafe-boilerplate

Test code

https://github.com/hex0cter/testcafe-boilerplate/blob/master/tests/test-duckduckgo-search.js

Specify your

  • operating system:
    iOS 12
  • testcafe version:
    0.21.1
  • node.js version:
    v10.8.0
@AndreyBelym AndreyBelym added the STATE: Need clarification An issue lacks information for further research. label Sep 19, 2018
@AndreyBelym AndreyBelym self-assigned this Sep 19, 2018
@AndreyBelym
Copy link
Contributor

Unfortunately I can't reproduce the issue, I've cloned the repository, and TestCafe has taken the screenshot. Could you please specify your OS version and provide me the full test report?

@hex0cter
Copy link
Author

hex0cter commented Oct 12, 2018

Hi, I was just able to reproduce the issue with the following procedures:

  1. Clone the repo: https://github.com/hex0cter/testcafe-boilerplate
  2. Run yarn test:local:remote on MacOS 10.12.6 with nodejs v8.11.4
  3. The QR code is printed on the screen.
  4. Take an iPhone with iOS 11.4.1/Mobile Safari 11.0.0 and scan the code.
  5. You will see the error once the tests runs.

Here are full logs:

~/tmp/testcafe-boilerplate(master ✔) yarn test:local:remote
yarn run v1.9.4
$ testcafe remote tests/ --qr-code --screenshots screenshots/remote
Connecting 1 remote browser(s)...
Navigate to the following URL from each remote browser.
You can either enter the URL or scan the QR-code.
Connect URL: http://10.3.193.227:54835/browser/connect

[ QR code image]

CONNECTED Mobile Safari 11.0.0 / iOS 11.4.1
 Running tests in:
 - Mobile Safari 11.0.0 / iOS 11.4.1

 Test Duckduckgo search
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open '/Users/daniel.han/tmp/testcafe-boilerplate/screenshots/remote/duckduckgo-screenshots.png'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
~/tmp/testcafe-boilerplate(master ✔) node --version
v8.11.4

@AndreyBelym
Copy link
Contributor

Thanks, I thought that the problem was in the BrowserStack configuration. I've reproduced the problem.

Unfortunately, you can't use window manipulation functionality (t.takeScreenshot, t.takeElementScreenshot, t.resizeWindow) in remote browsers. We should note this in documentation.

But TestCafe must emit a warning in this case and terminate gracefully instead of completely crashing the process. So it's a bug, and I need some time to investigate its reason.

@AndreyBelym AndreyBelym added TYPE: bug The described behavior is considered as wrong (bug). SYSTEM: browser natives AREA: server and removed STATE: Need clarification An issue lacks information for further research. labels Oct 12, 2018
@hex0cter
Copy link
Author

hex0cter commented Oct 12, 2018

Hi,

Thanks for helping out.

What do you mean by remote devices? What is the right way to take screenshots on those devices?

Best Regards,
Daniel Han

@AndreyBelym
Copy link
Contributor

Never mind, I mean I tried to run tests using the BrowserStack configuration, because you've specified iPhone as the target, and configuration's name is test:browserstack:iphone.

Remote browsers are browsers that you connect using the testcafe remote ... command. TestCafe can't take screenshots in this case, because in this case it can use only HTML APIs, that don't have reliable methods for taking screenshots.

@hex0cter
Copy link
Author

Thanks for the clarification Andrey!

@AndreyBelym AndreyBelym added this to the Planned milestone Oct 16, 2018
@AndreyBelym AndreyBelym modified the milestones: Planned, Sprint #22 Nov 13, 2018
AndreyBelym added a commit to AndreyBelym/testcafe that referenced this issue Nov 20, 2018
@LavrovArtem
Copy link
Contributor

@hex0cter
The fix was published in [email protected].

@lock
Copy link

lock bot commented Mar 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs or feature requests. For TestCafe API, usage and configuration inquiries, we recommend asking them on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 28, 2019
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this issue Dec 18, 2019
) (DevExpress#3137)

* Fix exceptions when screenshots failed to create (closes DevExpress#2878)

* Add tests

* Only chrome

* Handle error of npm.pack stream
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AREA: server STATE: Auto-locked An issue has been automatically locked by the Lock bot. SYSTEM: browser natives TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

4 participants