Get your setup working faster. Join our Discord for optimisation tips from elite testers.Join our Discord
Test Apple Pay on iOS devices
Learn how to test use cases around Apple Pay on iOS devices with Selenium on BrowserStack Automate
IMPORTANT
This feature is currently a Private Beta service and available only under Desktop and Mobile Pro, and Enterprise Pro plans. Contact our Support team or Sales team to enable this feature. For more details, check out our pricing page.
Setting this feature will lead to an increase in session start-time by 100-180 seconds. Thus, users are expected to use this feature based on their needs.
The Apple Pay feature in iOS devices enables purchases, one-click payments, and provides additional security for financial transactions. BrowserStack Automate enables you to test Apple Pay on remote iOS devices.
If you are using BrowserStack SDK, you can set the following capability within the configuration file:
Capability
Description
enableApplePay
Set this capability to "true" if you want to use Apple Pay in the test.
applePayPreferredNetworks
Set this capability if you want to set preferred payment networks for Apple Pay to improve stability. For example, ["Visa", "Mastercard"]. This capability is optional.
nativeWebTap
Set this capability to "true" if you are unable to get Apple Pay payment screen after clicking the Apple Pay button.
BrowserStack uses sandboxed cards provided by Apple for Apple Pay testing. These cards may occasionally fail due to card network instability or limitations.
To improve test stability, you can use the applePayPreferredNetworks capability to specify your preferred payment networks. BrowserStack automatically selects the most stable cards from your preferred networks and adds them to the test session.
This capability is optional, and if not specified, BrowserStack will use a default set of networks.
Set idleTimeout: 300 in browserstack.yml when running Apple Pay tests. Apple Pay setup takes longer than the default idle timeout. Without this setting, BrowserStack ends the session with a BROWSERSTACK_IDLE_TIMEOUT error. The maximum value for Automate is 300.
BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.
Set this capability to "true" if you want to use Apple Pay in the test.
applePayPreferredNetworks
Set this capability if you want to set preferred payment networks for Apple Pay to improve stability. For example, ["Visa", "Mastercard"]. This capability is optional.
nativeWebTap
Set this capability to "true" if you are unable to get Apple Pay payment screen after clicking the Apple Pay button.
Capability
Description
browserstack.enableApplePay
Set this capability to "true" if you want to use Apple Pay in the test.
browserstack.applePayPreferredNetworks
Set this capability if you want to set preferred payment networks for Apple Pay to improve stability. For example, ["Visa", "Mastercard"]. This capability is optional.
browserstack.nativeWebTap
Set this capability to "true" if you are unable to get Apple Pay payment screen after clicking the Apple Pay button.
BrowserStack uses sandboxed cards provided by Apple for Apple Pay testing. These cards may occasionally fail due to card network instability or limitations.
To improve test stability, you can use the applePayPreferredNetworks capability to specify your preferred payment networks. BrowserStack automatically selects the most stable cards from your preferred networks and adds them to the test session.
This capability is optional, and if not specified, BrowserStack will use a default set of networks.
Your test script must be modified with these custom executors along with the logic to select the UI elements in the webapp that triggers the Apple Pay payment, in the following order.
Trigger the payment workflow that uses Apple Pay as the payment method using your framework-specific commands.
Unable to get Apple Pay payment screen after clicking Apple Pay button?
To resolve this issue, perform any one of the following:
Set the appium:nativeWebTap capability to true.
Or, before you click the Apple Pay button, switch to native context using the following code snippet, and wait for a few seconds for the popup to appear.
If there are no context switching methods for the language or framework you are using, refer to the following Appium documentation:
Set Current Context or The Context API.
Once you complete any one of the above, run the BrowserStack executor for Apple Pay.
If you want to add Apple Pay details such as shipping, billing, or contact information, use the following JavaScript executor with the applePayDetails action.
For the Apple Pay details, ensure the details meet the following conditions:
In your shipping and billing addresses, only include parameters that apply to the addresses and remove the parameters that are not applicable. For example, if your test address doesnβt have a value for the province parameter, remove the parameter from the script.
For the geographical codes in your shipping and billing addresses, use only one of these parameters based on what your address requires and the device accepts: postalCode, postCode, zip. In the following code snippet, we have used postalCode.
The phone number must have the country code prefix with the + character. For example, use this +1-212-456-7890 or +12124567890.
Your session might fail if your test addresses donβt have the fields that the device requires. For example, if your test addresses have the zip parameter, but the device requires a different geographical code parameter, the session will fail. In this case, you can re-run the script with either postalCode or postCode and see which geographical code parameter the device accepts.