-
Notifications
You must be signed in to change notification settings - Fork 674
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
Screenshots in Chrome and Firefox on MacOS with --concurrency
are missing
#2095
Comments
@beyondcompute, really thank you for the excellent research! 👏 Yes, Systems Events likely can help in this case, but we try to avoid requesting Assistive Permissions as much as possible. As a workaround, you can try to use Headless mode for both Chrome and Firefox. TestCafe uses DevTools and Marionette debug protocols to capture screenshots in headless browsers, so they shouldn't be affected by problems with Applescripts. |
I've finally found the way to get screenshots in concurrency working on macOS even without requiring Assistive Perimssions. There is a method SBApplication.applicationWithProcessIdentifier for getting an AppleScript application object by a specified UNIX process ID. Unfortunately, it's only accessible from Objective C, and it means that I have to rewrite all our AppleScripts in Objective C, because each script needs access to an application object. |
Just wanted to say thank you to @AndreyBelym and all the TestCafe contributors for the incredible work you people are doing! 🙌 🎉 |
This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow. |
Are you requesting a feature or reporting a bug?
A bug.
What is the current behavior?
If you are taking screenshots while running with
--concurrency 2
(or more) in Chrome or Firefox (Safari works fine!) on Mac OS 10.12 Sierra, only one window takes screenshots. Others end up reporting:Not only thumbnails are missing but actual screenshots do not get created as well.
What is the expected behavior?
Screenshots to be taken, no warnings issued.
How would you reproduce the current behavior (if this is a bug)?
Patch
./bin/testcafe-with-v8-flag-filter.js 'chrome --disable-infobars' examples/basic/test.js --concurrency 2 --screenshots-on-fails --screenshots shots
Provide the test code and the tested page URL (if applicable)
See above
Specify your
0.18.6
and0.18.7-dev20180124
8.6.0
Some more info
It appears that
bin/mac/find-window.scpt
is able to locate only windows of the last open “application”. I.e., the code:always “tells” to the last opened application with certain
bundelId
and gets only its window informationSo
this.windowDescriptors
here end up looking like:(if we run two instances)
Interesting, that in Firefox
cocoaId
seems to matchwindowId
(In Chrome they are different):Because of this, screenshot gets created only for non-null descriptor windows (neither
bin/mac/find-window-cocoa
norbin/mac/screenshot
get called for thenull
one). This all goes silently and only in the endbin/mac/generate-thumbnail
is executed for all screenshots and fails in those cases where screenshots were not created in the first place.Now, I spent some time trying to modify the
src/natives/find-window/mac/find-window.applescript
to handle the situation when many apps are running with the same bundleId but to no avail (I am no Applescript expert). It is possible to get names of all windows of all process usingtell application "System Events"
butSystem Events
has no information about any “window ids”. Also this requires Assistive Permissions!I was able to modify the
find-window-cocoa.m
Approximately like this:
so that it returns
bundleId
andcocoaId
of the first window, whose name contains certain text (I am no Objective C expert either). But I am not aware of the way of obtaining the “Applescript’s”windowId
this way. So it rendersnatives/close/mac/close.applescript
and others useless. Because:will not work with
cocoaId
(and in case of Chrome they are different).The text was updated successfully, but these errors were encountered: