Krishna
Krishna

Reputation: 206

Intermittent failure when clicking "Allow Access to All Photos" button in iOS App,mistakenly clicking "Don't Allow" instead, using Appium iOS

I am writing automation tests for an iOS App, where it requires access to 'Select Photos...', 'Allow Access to All Photos', and 'Don't Allow'. I am using Appium 2.0 with Webdriver.io, running on BrowserStack with an iOS 16.3 device.

Initially, I used the 'name' locator strategy for the 'Allow Access to All Photos' button, as it is unique. It worked for a couple of times and then started failing intermittently. When I checked the execution video, it's actually clicking the 'Don't Allow' button.

So, I changed the locator strategy to use the iOS Predicate as follows: type == "XCUIElementTypeButton" AND label == "Allow Access to All Photos" AND name == "Allow Access to All Photos". However, it still fails intermittently with the error: "Error: element ("-ios predicate string:type == "XCUIElementTypeButton" AND label == "Allow Access to All Photos" AND name == "Allow Access to All Photos"") still not displayed after 10000ms", but it's actually clicking the 'Don't Allow' button in the video.

const allowAccessToAllPhotosButton = await this.allowAccessToAllPhotosButton;
await allowAccessToAllPhotosButton.waitForDisplayed();
await allowAccessToAllPhotosButton.click();

get allowAccessToAllPhotosButton(): Promise<WebdriverIO.Element> {
    return getElementByPredicate(IOSPredicate.ALLOW_ACCESS_TO_ALL_PHOTOS_BUTTON);
}

Upvotes: 0

Views: 430

Answers (1)

A P
A P

Reputation: 376

Could you please try the autoAcceptAlerts bstack:options capability, and see if it's auto-accepting the popup or not. For ref.: https://www.browserstack.com/docs/app-automate/appium/advanced-features/handle-permission-pop-ups

Upvotes: 0

Related Questions