Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Failed to get matching snapshots #83

Open
onmyway133 opened this issue Nov 1, 2019 · 14 comments
Open

Failed to get matching snapshots #83

onmyway133 opened this issue Nov 1, 2019 · 14 comments

Comments

@onmyway133
Copy link

Thanks for the library. I have an issue with the latest release

Assertion Failure: MonkeyXCTest.swift:33: Failed to get matching snapshots: Timed out while evaluating UI query.

Here is my setup

func testMonkey() {
    let monkey = Monkey(frame: app.frame)
    monkey.addDefaultUIAutomationActions()
    monkey.addXCTestTapAlertAction(interval: 100, application: app)
    monkey.monkeyAround()
}
@wojciechczerski
Copy link
Member

Hey there! Is the sample App working for you? Also, are you integrating the library from CocoaPods repository, or are you referencing SwiftMonkey directly from GitHub (master)?

@onmyway133
Copy link
Author

@wojciechczerski Hi, thanks for quick response. I use CocoaPods, and I see it origins from this call addXCTestTapAlertAction

@wojciechczerski
Copy link
Member

Could you try referencing SwiftMonkey in your Podfile like that:

pod 'SwiftMonkey', :git => 'https://github.com/zalando/SwiftMonkey.git'

I would like to check whether perhaps the existing code on master could solve your issue.

@onmyway133
Copy link
Author

@wojciechczerski ja will try, and also I have this issue which happens only during monkey tests

Failed to determine hittability of Button: Unable to fetch parameterized attribute XC_kAXXCParameterizedAttributeConvertHostedViewPositionFromContext, remote interface does not have this capability.

@wojciechczerski
Copy link
Member

When you fetch the code from GitHub, could you also try replacing monkey.addDefaultUIAutomationActions with monkey.addDefaultXCTestPublicActions(app: application)? I know it's not really solving the issue but maybe using XCTest public action could at least get you going while the issue is being solved.

@onmyway133
Copy link
Author

@wojciechczerski seems to work, thanks

@adario
Copy link

adario commented Dec 2, 2019

@wojciechczerski any news about this issue?
I'm using the GitHub version in my Podfile (currently at 2.1.1), and the matching snapshots failure is still present.
Regarding your suggestion to use monkey.addDefaultXCTestPublicActions(app: application) --
that method does not appear to be available.
Thank you.

@wojciechczerski
Copy link
Member

@adario Hey there! Is this how your Podfile looks like?

pod 'SwiftMonkey', :git => 'https://github.com/zalando/SwiftMonkey.git'

If the monkey.addDefaultXCTestPublicActions method is not present, perhaps there is some caching issue that's preventing pulling the latest version. In such case you could try deleting the Pods directory and running pod install again.

@adario
Copy link

adario commented Dec 3, 2019

@wojciechczerski Hey there, thanks for the quick reply —
yes, my Podfile contains the :git statement to locate the pod, so I'm on the latest (I assume: pod install reports version 2.1.1).
The method is indeed missing: I've looked at the sources, and couldn't find it.

@wojciechczerski
Copy link
Member

Have you tried deleting the Pods directory so that SwiftMonkey gets reinstalled. Another thing to try could be to delete Podfile.lock. Alternatively, just to be sure you are getting the lastest sources, you could try adding this to your Podfile (as a test):

pod 'SwiftMonkey', :git => 'https://github.com/zalando/SwiftMonkey.git', :commit => '68f49bb69381103224b0e77ab615baac8b1fd750'

Please let me know whether that helps.

@adario
Copy link

adario commented Dec 4, 2019

@wojciechczerski adding the commit ID in the Podfile (after manually removing Podfile.lock and Pods) seems to work — that is, the addDefaultXCTestPublicActions method is now visible...
Is the method supposed to work on actual devices, or only on the simulator?
Thank you.

@adario
Copy link

adario commented Dec 4, 2019

It looks like the public actions do work on actual devices — cool!
Is it possible to add extra actions besides tap, press and drag?
Thank you.

@wojciechczerski
Copy link
Member

Glad to hear it worked for you! As for adding extra actions - I am not sure. SwiftMonkey used to support quite a lot of actions, this was however possible due to usage of private APIs. These APIs do not exist anymore therefore public XCTest actions are used. Maybe it would be possible to combine these actions to simulate a pinch or rotate gestures, but I haven't checked that yet (it's still on my TODO).

@adario
Copy link

adario commented Dec 4, 2019

@wojciechczerski I've tried adding public XCTest actions for swipe and rotate: unfortunately, they're not very useful. That is, they are executed correctly, as well as shown by MonkeyPaws, but since they're run via the application XCUIElement instead of XCUICoordinate, they don't produce the expected results because of truly counterintuitive locations...
For instance, the rotate gesture is applied to the edges of the screen, instead of around the center of the screen, which obviously results in no rotation at all. Conversely, the swipe gestures are applied around the screen center, instead of from the screen edges.

This was referenced Mar 18, 2020
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

3 participants