Cannot find/click any elements on Apple Pay view in UITest
I've been able to successfully run ApplePay in my UITests, but once the PKPaymentAuthorizationViewController is displayed, none of the elements on that view are locatable and any attempt to select elements on the underlying application view result in an error "..... is not frontmost".
Has anyone else encountered this problem and/or have any idea how to work around it?
The Apple Pay UI is presented out of process (even though you trigger it with a
UIViewController subclass), so I don't think you'll be able to pick it up with UI testing. It's presented out of process so that an app can't modify or manipulate the Apple Pay views.
UI Testing cannot interact with anything outside of your application. In your scenario, the framework can no longer do anything once your app presents the Apple Pay view.
To verify this, try printing out the app's hierarchy once the view appears. You will notice that nothing in Apple Pay nor the navigation bar will show up - you will only see your app's information.
XCUITest: tap() method doesn't wor…, Is it possible that the use of the tap() method doesn't work on UITableViews when let app = XCUIApplication() let myTableView = app.tables.element(matching: On the command line I get the log as the action should've been computed but on We found a solution that doesn't require any change of your UITest script. Apple has built a robust set of services to help users get even more utility and productivity out of their devices. These services include Apple ID, iCloud, Sign in with Apple, Apple Pay, iMessage, FaceTime, and Find My. Learn how Apple makes their services secure
It is a bit tricky, but here is how you can do this:
// create passbook app let applePay = XCUIApplication(bundleIdentifier: "com.apple.PassbookUIService") // wait for an auth controller to appear _ = applePay.wait(for: .runningForeground, timeout: 5) // tap pay button applePay.buttons["Pay with Passcode"].tap()
After that authorization will succeed and you'll get apple pay data.
But there is "one more thing" - data will be empty on simulator, so if you try to serialize it, you'll get an error. So I used data mock for simulator:
#if targetEnvironment(simulator) print("WARNING! SIMULATING APPLE PAY!") let payObject = [String: Any]() #else let payObject = try JSONSerialization.jsonObject(with: encryptedData, options: ) #endif // send payObject to server
UITesting not finding UIButton, but I cannot find the button, it just does not exist anywhere, it runs find in the simulator and I can even click the button, however the button does not exist when running a UITest. let button = app.buttons["myButton"]. Any Ideas? it as an " Other Element" and tapping it ends up with tapping the view(?) from the looks of it . A: Apple Pay requests have to be generated when the page is loaded. As such, we can’t later “pull in” the variations that have been selected to ensure the order is accurate. Since we can’t get this data into the Apple Pay form in any way, Apple Pay “Buy Now” buttons cannot be enabled for variable products.
How to target an offscreen cell in…, Given that the cell is offscreen, it isn't dequeued, and therefore I can't find the XCUIElement for the specific (imagine my desired element was in the middle of a very large table view, I wouldn't want to say *scroll to bottom*). If a cell is offscreen, an attempt to get the UI test system to tap it will have no effect. Give it a try. Upon opening the app to set up Apple Pay, it will ask if you want to use your credit or debit card already on file for iTunes purchases or add a new card. Step 4: Pick a Card, Not Quite Any Card
UI Testing: Failed to get refreshe…, After pressing a button that loads a new page I get an error saying "UI Testing Failure - Failed to get refreshed snapshot". The previous page where I press the button works fine. the displays change the elements are re-evalutated to get the most current data. Joar, do you know of any updates regarding this bug? thanks. The next thing to try would be to rescan these images if you can. Also, if you have the original files saved in another location, remove one of the scanned JPEGs from iCloud Photos, then upload it again from the original file. See if there is any change. If you're unable to do this step, or if the issue persists, Contact Apple Support. Cheers!
The Payment Request Button lets your customers check out with Apple Pay, Google Pay, Chrome saved cards, and Microsoft Pay. When using an Apple Pay-enabled browser, your customer will see the button on the left below. When using a browser that supports the Payment Request API, they’ll see the button on the right below.