Can anyone help me with clicking the "Allow" button on a native popup in iOS11 or later? I'm struggling to determine the xpath for this popup, and any suggestions would be greatly appreciated.
I've attempted switching to the correct context, which I believe is NATIVE_APP, and using various xpath locators to click the option, but haven't had any success.
I suspect that my approach is correct, but the issue lies with the xpath itself.
The 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"');
}
);
However, I keep encountering an error message stating: "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 following approach works in iOS11 and iOS12, but is quite slow in 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"]’);
}
);
For iOS10:
browser.execute('mobile:alert', {
notification
action: 'accept',
buttonLabel: 'Allow'
});