lyft / hammer Goto Github PK
View Code? Open in Web Editor NEWiOS touch synthesis library
License: Apache License 2.0
iOS touch synthesis library
License: Apache License 2.0
I wonder if you ever got Hammer to work with SwiftUI Lists. We've played around with the .accessibiliy(identifier:) View modifier and that has worked for creating UI Tests within Xcode, however when we tried to locate the Lists with Hammer we seem to have found that no UIViews in the view hierarchy are given the accessibility identifiers we gave to the List Views.
Just to move forward, I've used the .accessibility(label:) view modifier as well and written an extension on UIView which recursively hunts all subviews for the first UIView matching a given test and tested the UIView.accessibilityLabel instead. At least once the UIView is identified we can then use it with Hammer.
Have you folks tried hunting SwiftUI-built objects much and had you found Lists don't play nicely?
Hi from Japan👋🏻
I see waitUntilHittable
in testcases a lot, but it seems like self.defaultTouchLocation
is never nil or throws error, so what is the point?
is it possible to add and publish a podspec for this project? i still use cocoapods and cannot use SPM.
Describe the bug
let eventGenerator = try EventGenerator(view: tabs) let cell = try eventGenerator.viewWithIdentifier( "image_tab_button_Tab 1", ofType: ImageTabs.Button.self, timeout: 1 ) try eventGenerator.fingerTap(at: cell)
Locally we can run these tests as often as we want. I have recently been running these tests 100 times in a row with & without building and I never see a failure. When I push to our remote CI system we are seeing failures (maybe 50% of the time) with
failed: caught error: "The app or window is not ready for interaction. Ensure that your tests are running in a host application and that you have given enough time for the view to present on screen. For more troubleshooting tips see: https://github.com/lyft/Hammer#troubleshooting." (#CharacterRangeLen=0)
I have attempted adding waits
try eventGenerator.waitUntilHittable(timeout: 2)
but no matter how long the timeout is I am seeing the above error thrown.
Thank you for creating Hammer!
I’d like to tap on an item in the callout bar, which lives in the text effects window. This is what I have so far:
let textEffectsWindow = UIApplication.textEffectsWindow /// A helper I wrote.
textEffectsWindow.makeKey() /// Otherwise, initializing an EventGenerator on the next line will throw.
let eventGeneratorForTextEffectsWindow = try EventGenerator(window: textEffectsWindow)
let linkButton = try eventGeneratorForTextEffectsWindow.viewWithLabel("Link") /// A helper I wrote to get a view by its `accessibilityLabel`.
try eventGeneratorForTextEffectsWindow.fingerDown(at: linkButton) /// This line throws `HammerError.viewIsNotHittable`.
try eventGeneratorForTextEffectsWindow.fingerUp()
window.makeKey() /// Makes my main window key again so I can proceed with my test.
fingerDown(at:)
throws on line 264 of Subviews.swift since self.window.hitTest(hitPoint, with: nil)
returns the entire UICalloutBar
, not the UICalloutBarButton
linkButton
. Do you have any experience with the callout bar?
Thank you!
Hi! Thanks for putting together this library, more ways to avoid scenario tests but still tap around are great! :D
Question here more than an issue: currently, this can only be used with UIKit views (it seems), but this could be extended to WatchKit, right? Is that something that you've attempted before? Thanks!
Cool tool. Seems like events don't work for this controller due to security. Perhaps you can/want to find a way to its heart.
We are bringing in Hammer via Swift PM and including it under Build Phases > Link Binary With Libraries for a test target.
Our project compiles fine under Xcode 12.5.1 but with Xcode 13 beta 4 I get a compiler error about Hammer’s use of UIApplication.shared
:
'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.
I tried cloning Hammer and compiling it for an iOS 15 sim and hit the same error.
Describe the bug
Xcode 13.3 can't compile an App-project which contains Hammer 0.14.0
To Reproduce
Expected behavior
Project builds successfully with Hammer
Environment (please complete the following information):
Additional context
We have added a sample project in https://github.com/awBSH/lyft-hammer-xcode13.3
�Hey there,
I started seeing new type of warning logs as I generate touch events. However it doesn't seem to affect the functionality. Do you know why this started happening?
2022-07-22 14:38:11.471364-0400 IntegrationTestHost[36563:3464107] [EventDispatcher] Found no UIEvent for backing event of type: 1; contextId: 0x9DE5CC17; Event will not be dispatched
2022-07-22 14:38:11.473324-0400 IntegrationTestHost[36563:3464107] [EventDispatcher] Found no UIEvent for backing event of type: 1; contextId: 0x9DE5CC17; Event will not be dispatched
2022-07-22 14:38:11.491951-0400 IntegrationTestHost[36563:3464107] [EventDispatcher] Found no UIEvent for backing event of type: 1; contextId: 0x9DE5CC17; Event will not be dispatched
Another question I have is how are you guys handling the flakiness for Hammer in testing. Although not very often, my tests which rely on using Hammer shows flakiness in CI build machines. Do you encounter similar problems? Do you have any tips on how to mitigate it?
Thanks in advance @gabriellanata
Describe the bug
After two finger downs it is not possible to up single finger – both touches are ending
To Reproduce
Code to reproduce:
func testBug() throws {
try eventGenerator.wait(1)
try eventGenerator.fingerDown([.rightThumb, .rightIndex],
at: [
CGPoint(x: 200, y: 400),
CGPoint(x: 400, y: 400)
])
try eventGenerator.wait(1)
try eventGenerator.fingerUp([.rightThumb])
try eventGenerator.wait(3)
try eventGenerator.fingerUp([.rightIndex])
try eventGenerator.wait(3)
}
Expected behavior
Single finger released allowing to manipulate the second one.
I have a scenario where I do zooming then release one finger and starting to pan the map view.
Screenshots
If applicable, add screenshots to help explain your problem.
There is an extra framework to visualise touches with handling phases and locations via UIApplication.sendEvent
. Circle animation starts when touch in the Ended phase was received.
Environment (please complete the following information):
Additional context
UIApplication.sendEvent
receives two UITouch events with the Ended phase.
Add any other context about the problem here.
Test Case '-[DebugAppTests.DebugAppTests testBug]' started (Iteration 1 of 3).
<UITouchesEvent: 0x60000331a490> timestamp: 178537 touches: {(
<UITouch: 0x1288461a0> phase: Began tap count: 1 force: 0.000 window: <MBXFingerTipWindow: 0x11fe07840; baseClass = UIWindow; frame = (0 0; 1133 744); gestureRecognizers = <NSArray: 0x60000066a6d0>; layer = <UIWindowLayer: 0x60000066a520>> responder: (null) ,
<UITouch: 0x128838560> phase: Began tap count: 1 force: 0.000 window: <MBXFingerTipWindow: 0x11fe07840; baseClass = UIWindow; frame = (0 0; 1133 744); gestureRecognizers = <NSArray: 0x60000066a6d0>; layer = <UIWindowLayer: 0x60000066a520>> responder: <MTKView: 0x12981e400; frame = (0 0; 1133 744); layer = <CAMetalLayer: 0x600000666e80>> location in window: {200, 400} previous location in window: {200, 400} location in view: {200, 400} previous location in view: {200, 400}
)}
2023-02-15 13:41:11.608328+0200 DebugApp[69948:3352821] [Window] Manually adding the rootViewController's view to the view hierarchy is no longer supported. Please allow UIWindow to add the rootViewController's view to the view hierarchy itself.
<UITouchesEvent: 0x60000331a490> timestamp: 178537 touches: {(
<UITouch: 0x1288461a0> phase: Began tap count: 1 force: 0.000 window: <MBXFingerTipWindow: 0x11fe07840; baseClass = UIWindow; frame = (0 0; 1133 744); gestureRecognizers = <NSArray: 0x60000066a6d0>; layer = <UIWindowLayer: 0x60000066a520>> responder: (null) ,
<UITouch: 0x128838560> phase: Began tap count: 1 force: 0.000 window: <MBXFingerTipWindow: 0x11fe07840; baseClass = UIWindow; frame = (0 0; 1133 744); gestureRecognizers = <NSArray: 0x60000066a6d0>; layer = <UIWindowLayer: 0x60000066a520>> responder: <MTKView: 0x12981e400; frame = (0 0; 1133 744); layer = <CAMetalLayer: 0x600000666e80>> location in window: {200, 400} previous location in window: {200, 400} location in view: {200, 400} previous location in view: {200, 400}
)}
2023-02-15 13:41:11.707522+0200 DebugApp[69948:3352821] [EventDispatcher] Found no UIEvent for backing event of type: 1; contextId: 0x91D53B81
<UITouchesEvent: 0x60000331a490> timestamp: 178538 touches: {(
<UITouch: 0x1288461a0> phase: Ended tap count: 0 force: 0.000 window: <MBXFingerTipWindow: 0x11fe07840; baseClass = UIWindow; frame = (0 0; 1133 744); gestureRecognizers = <NSArray: 0x60000066a6d0>; layer = <UIWindowLayer: 0x60000066a520>> responder: (null) ,
<UITouch: 0x128838560> phase: Ended tap count: 0 force: 0.000 window: <MBXFingerTipWindow: 0x11fe07840; baseClass = UIWindow; frame = (0 0; 1133 744); gestureRecognizers = <NSArray: 0x60000066a6d0>; layer = <UIWindowLayer: 0x60000066a520>> responder: <MTKView: 0x12981e400; frame = (0 0; 1133 744); layer = <CAMetalLayer: 0x600000666e80>> location in window: {200, 400} previous location in window: {200, 400} location in view: {200, 400} previous location in view: {200, 400}
)}
<UITouchesEvent: 0x60000331a490> timestamp: 178538 touches: {(
<UITouch: 0x1288461a0> phase: Ended tap count: 0 force: 0.000 window: <MBXFingerTipWindow: 0x11fe07840; baseClass = UIWindow; frame = (0 0; 1133 744); gestureRecognizers = <NSArray: 0x60000066a6d0>; layer = <UIWindowLayer: 0x60000066a520>> responder: (null) ,
<UITouch: 0x128838560> phase: Ended tap count: 0 force: 0.000 window: <MBXFingerTipWindow: 0x11fe07840; baseClass = UIWindow; frame = (0 0; 1133 744); gestureRecognizers = <NSArray: 0x60000066a6d0>; layer = <UIWindowLayer: 0x60000066a520>> responder: <MTKView: 0x12981e400; frame = (0 0; 1133 744); layer = <CAMetalLayer: 0x600000666e80>> location in window: {200, 400} previous location in window: {200, 400} location in view: {200, 400} previous location in view: {200, 400}
)}
2023-02-15 13:41:12.907412+0200 DebugApp[69948:3352821] [EventDispatcher] Found no UIEvent for backing event of type: 1; contextId: 0x91D53B81
Describe the bug
A view is deemed "not visible" by the library upon finger tap, even if the view is visible but outside the superview's bounds.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
View should be hittable.
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
Additional context
Bug is pretty clear and easy to reproduce.
Below is the problematic condition.
func isVisible(_ rect: CGRect, visibility: EventGenerator.Visibility = .partial) -> Bool {
switch visibility {
case .partial:
return self.intersects(rect)
case .center:
return self.contains(rect.center)
case .full:
return self.contains(rect)
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.