Skip to content

Commit

Permalink
fix: fix iOS deeplink
Browse files Browse the repository at this point in the history
  • Loading branch information
wswebcreation committed Jan 6, 2024
1 parent 2dea0c4 commit 5d79327
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/helpers/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ export async function openDeepLinkUrl(url:string) {
// - https://blog.diawi.com/2018/10/15/2018-apple-devices-and-their-new-udid-format/
// - https://www.theiphonewiki.com/wiki/UDID
// iOS sims have more than 1 `-` in the UDID and the UDID is being
const simulatorRegex = new RegExp('(.*-.*){2,}');
const realDeviceRegex = /^[a-f0-9]{25}|[a-f0-9]{40}$/i;

// Check if we are a simulator
if ('appium:udid' in driver.capabilities && simulatorRegex.test(driver.capabilities['appium:udid'] as string)){
await driver.url(`${ prefix }${ url }`);
} else {
// Else we are a real device and we need to take some extra steps
// Check if we are a real device
if ('appium:udid' in driver.capabilities && realDeviceRegex.test(driver.capabilities['appium:udid'] as string)){
// Launch Safari to open the deep link
await driver.execute('mobile: launchApp', { bundleId: 'com.apple.mobilesafari' });

Expand All @@ -55,6 +52,9 @@ export async function openDeepLinkUrl(url:string) {

// Submit the url and add a break
await urlField.setValue(`${ prefix }${ url }\uE007`);
} else {
// Else we ne are a simulator
await driver.url(`${ prefix }${ url }`);
}

/**
Expand Down

0 comments on commit 5d79327

Please sign in to comment.