Skip to content

Commit

Permalink
Use new notification tile identifier for iOS 18 (#2394)
Browse files Browse the repository at this point in the history
* Use new notification tile identifier for iOS 18

* Update changelog

---------

Co-authored-by: piotruela <[email protected]>
  • Loading branch information
piotruela and piotruela authored Nov 8, 2024
1 parent 19a325f commit ced0eac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/patrol/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

- Fix tapping on notification on iOS 18. (#2394)

## 3.12.0

- Add `clear-permissions` flag on ios commands. (#2367)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,14 @@

// MARK: Notifications

private let notificationCellIdentifier: String = {
if #available(iOS 18, *) {
return "ListCell"
} else {
return "NotificationCell"
}
}()

func openNotifications() throws {
// TODO: Check if works on iPhones without notch

Expand Down Expand Up @@ -667,7 +675,7 @@
func getNotifications() throws -> [Notification] {
var notifications = [Notification]()
runAction("getting notifications") {
let cells = self.springboard.buttons.matching(identifier: "NotificationCell")
let cells = self.springboard.buttons.matching(identifier: self.notificationCellIdentifier)
.allElementsBoundByIndex
for (i, cell) in cells.enumerated() {
Logger.shared.i("found notification at index \(i) with label \(format: cell.label)")
Expand All @@ -681,7 +689,8 @@

func tapOnNotification(byIndex index: Int, withTimeout timeout: TimeInterval?) throws {
try runAction("tapping on notification at index \(index)") {
let cellsQuery = self.springboard.buttons.matching(identifier: "NotificationCell")
let cellsQuery = self.springboard.buttons.matching(
identifier: self.notificationCellIdentifier)
guard
let cell = self.waitFor(query: cellsQuery, index: index, timeout: timeout ?? self.timeout)
else {
Expand All @@ -703,7 +712,8 @@
try runAction("tapping on notification containing text \(format: substring)") {
let cellsQuery = self.springboard.buttons.matching(
NSPredicate(
format: "identifier == %@ AND label CONTAINS %@", "NotificationCell", substring)
format: "identifier == %@ AND label CONTAINS %@", self.notificationCellIdentifier,
substring)
)

guard let cell = self.waitFor(query: cellsQuery, index: 0, timeout: timeout ?? self.timeout)
Expand Down

0 comments on commit ced0eac

Please sign in to comment.