Avishai Yaniv
Avishai Yaniv

Reputation: 410

Auto dismiss Apple id verification pop up

I am using selenium and Appium for automation tests. I'm trying to figure out how to auto dismiss the Apple id verification pop up on the ipad and iPhone devices before each test.

I have tried to write

iosDriver.SwitchTo().Alert().Dismiss()

with no success so far.

I have also seen somthing like

driver.findElement(By.xpath("//*[@XCElementType='XCUIElementTypeButton'][3]")).click();

but I do not know how to identify the "not now" button.

capabilities.SetCapability("platformName", "iOS");
        capabilities.SetCapability("platformVersion", iosPlatformVersion);
        capabilities.SetCapability("browserName", string.Empty);
        capabilities.SetCapability("deviceName", deviceName);
        capabilities.SetCapability("automationName", "XCUITest");
        capabilities.SetCapability("bundleId", "com.*****.automation");
        capabilities.SetCapability("udid", iphone_udid);
        capabilities.SetCapability("noReset", "true");
        capabilities.SetCapability("fullReset", "false");
        capabilities.SetCapability("xcodeConfigFile", "/Users/******/Desktop/***.xconfig");
        capabilities.SetCapability("agentPath", "/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj");
        capabilities.SetCapability("bootstrapPath", "/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent");
        capabilities.SetCapability("startIWDP", true);
        capabilities.SetCapability("autoDismissAlerts", true);
        string pathTo****Ipa = null; pathIpa = string.IsNullOrEmpty(path) ? ipaPath : path1;
        capabilities.SetCapability("app", path);
        //XCUITest
        capabilities.SetCapability("waitForAppScript", "$.delay(5000); $.acceptAlert();");
        IOSDriver<IOSElement> driver = new IOSDriver<IOSElement>(new Uri("http://127.0.0.1:****/**/***"), capabilities, new TimeSpan(0, 3, 0));

would love to hear from people who succeeded in such cases.

Thasnks in advacne.

enter image description here

Upvotes: 3

Views: 520

Answers (1)

Sal Coraccio IV
Sal Coraccio IV

Reputation: 51

if you are only concerned for this for iOS you can use $driver.find_element(name: 'Not Now'). Just translate from ruby.

alternatively: $driver.find_element(predicate: "type='XCUIElementTypeButton' AND name MATCHES[cd] 'Not Now'") <- also in ruby.

I would really avoid using XPath if you can - it's not going to be consistent in the long run.

Upvotes: 0

Related Questions