简体   繁体   中英

Click “Allow” in iOS native popup

I am probably missing something here but I am trying to click "Allow" for a native popup in iOS11 +. If anyone has any idea on how to determine what the xpath is for this native popup or any other ideas it would save me a lot of headache!

I have tried to switch the correct context, NATIVE_APP I believe, then use an xpath locator click the option but no luck at all.

I think I am on the right track but the xpath just being incorrect.

xpaths I have tried are:

@label="Allow"
//*[. = 'Allow']
//*[contains(text(), 'Allow')]

```browser.contexts(async function (context) {
    browser.setContext(context['value'][0]); //switch to native

browser
.useXpath()
.click('@label="Allow"');
}
);```

Error message being,

An error occurred while running .click() command on <@label="Allow">: An element could not be located on the page using the given search parameters.

Update The below works for iOS11 and iOS12, but is extremely slow for iOS11

browser.contexts(async function (context) {
  console.log("this is all the contexts: " + context.value);
  browser.setContext(context['value'][0]); //switch to native

  browser
     .useXpath()
     .click('//*[@name="Allow"]’);
}
);

iOS10 browser.execute('mobile:alert', { notification action: 'accept', buttonLabel: 'Allow' });

I am trying to click "Allow" for a native popup in iOS11

Are you describing a permissions dialog, like a location, contact, or photos permission dialog ?

If so, you cannot interact with these from your application. The user must explicitly tap an "Allow" button to grant permissions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM