Automating Custom Alert Buttons on iOS
iOS alert treatment has often been a testy subject (pun! pun!). Luckily, with the current XCUITest driver used by Appium, we can connect directly to Apple-approved method for accepting or dismissing an alerting, or even getting its schoolbook. Appium provides approach to this behavior via the standard suite of WebDriver alert commands, for example: Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script. Unfortunately, the WebDriver spec is not quite as flexible as mobile apps when it comes to the pattern of alerts. The WebDriver spec was found around web browser alerts, which can contain at most two action buttons. Mobile apps can make native alerting which carry 3 or even more button! So, what do you do when you need to automatize the action associated with a push which is not & quot; OK & quot; or & quot; Cancel & quot;? For example, I & # x27; ve added a feature toThe App& # x27; s list view which enables you to tap a third awake button when you choose a cloud character: When you tap this 3rd button, another alert appears with some extra information about the cloud type: But backwards to the maiden alert. We want to click the & quot; Learn more about Cirrostratus & quot; brisk option. In this suit, we could probably use the fact that we know the name of the button to find it in the UI hierarchy. But what if we didn & # x27; t know the text of the button, only that we wanted to tap the third push, whatever it contains? Luckily, Appium has a special dictation for handling alerts on iOS that you can use for this purpose:mobile: alarm. This command does allow you to accept and dismiss alert as usual, but that & # x27; s not very interesting. We & # x27; re going to look at two new use cases: getting a list of the available push labels and tapping an alert action via its label. These characteristic together will aid resolve the problem under consideration. Let & # x27; s take a look at an example: Following the pattern of the other mobile: method, we use executeScript with a special command and parameters to get the list of push labels. Once we feature this list, we can do whatever we need with it. Today, we & # x27; ll only try to extract the first label which isn & # x27; t one of the defaults (taking care to shed an exception if there is no such label): At this point, we hold the value of the button we want to press in thebuttonLabelvarying. We can again usemobile: alert to target this specific button, using a differentaction parameter than before (with a value of& quot; accept & quot;), and bring the new parameterbuttonLabelto let Appium know which push we want it to tap for us: That & # x27; s all there is to it! Usingmobile: alarumwe have approach to the full set of lively activity that can be displayed in an iOS app. See the full example below to see it work in the setting of my test app or check out the codificationon GitHub! Lead, Content Marketing, HeadSpin Inc. Piali is a dynamical and results-driven Content Marketing Specialist with 8+ years of experience in crafting absorb tale and market collateral across various industries. She excels in collaborating with cross-functional teams to develop advanced content strategies and deliver compelling, authentic, and impactful substance that resonates with prey audiences and enhances make authenticity. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts..png)



Automating Custom Alert Buttons on iOS
AI-Powered Key Takeaways
driver.switchTo () .alert () .alert () driver.switchTo () .alert () .dismiss () driver.switchTo () .alert () .getText ()Check out:


Also check:
HashMapString buttonLabel = null; for (String button: buttons) {if (button.equals (`` OK '') || button.equals (`` Cancel '')) {continue;} buttonLabel = button;} if (buttonLabel == zippo) {throw new Error (`` Did not get a third rattling push as we were expecting '');}args.put (`` activity '', `` accept ''); args.put (`` buttonLabel '', buttonLabel); driver.executeScript (`` mobile: alarm '', args);import io.appium.java_client.MobileBy; import io.appium.java_client.MobileElement; import io.appium.java_client.ios.IOSDriver; import java.io.IOException; signification java.net.URL; importation java.util.HashMap; import java.util.List; import org.junit.After; import org.junit.Before; meaning org.junit.Test; import org.openqa.selenium.By; importee org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public grade Edition031_iOS_Alerts {private String APP = `` https: //github.com/cloudgrey-io/the-app/releases/download/v1.6.1/TheApp-v1.6.1.app.zip ''; individual IOSDriver driver; private WebDriverWait hold; private By listView = MobileBy.AccessibilityId (`` List Demo ''); private By cloud = MobileBy.AccessibilityId (`` Cirrostratus ''); @ Before public nothingness apparatus () throws IOException {DesiredCapabilities caps = new DesiredCapabilities (); caps.setCapability (`` platformName '', `` iOS ''); caps.setCapability (`` platformVersion '', `` 11.4 ''); caps.setCapability (`` deviceName '', `` iPhone 6 ''); caps.setCapability (`` app '', APP); driver = new IOSDriverPiali Mazumdar
Automating Custom Alert Buttons on iOS
4 Parts
-1280X720-Final-2.jpg)
Regression Intelligence practical guide for advanced user (Part 3)
-1280X720-Final-2.jpg)
Regression Intelligence hard-nosed guide for advanced users (Part 4)
Discover how HeadSpin can empower your business with superior testing capacity







Discover how HeadSpin can empower your business with superior prove capabilities
Discover how HeadSpin can empower your concern with superior testing capabilities
Connet Now


Automate This With SUSA
Test Your App Autonomously







.png)












