Mobile Safari Automation On iOS Real Device


#1

Environment

  1. Mac OS/version: 10.13.2 Sierra
  2. Carthage Version: 0.25.0
  3. XCode version: 9.2
  4. iOS Device Version: 11.2

Install Appium Server
Appium .dmg file & Appium Java Client
http://appium.io/downloads.html
Selenium webdriver jar
http://www.seleniumhq.org/download/

Run below Terminal Commands
brew install libimobiledevice

brew install carthage

npm install -g ios-deploy

brew install ios-webkit-debug-proxy

Install “SafariLauncherApp” on iPhone/Simulator
Create a provisioning profile that can be used to deploy the SafariLauncherApp on device.

Install WebDriverAgent
-Open WebDriverAgent in xcode
/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
-Select “WebdriverAgentRunner” in Xcode & Select Target as iPhone
-Add bundle identifier & valid certificate (p.12)
(Targets)
-WebDriverAgentLib (Add bundle Identifier)
-WebdriverAgentRunner (Add bundle Identifier)
-Unit Tests (Add bundle Identifier)
-IntegrationTets_1 (Add bundle Identifier & Target App as “IntegrationApp”)
-IntegrationTets_2 (Add bundle Identifier & Target App as “IntegrationApp”)
-IntegrationTets_3 (Add bundle Identifier & Target App as “IntegrationApp”)
-IntegrationApp (Add bundleIdentifire)

Start iOS webkit debug proxy
Running and listening on port 27753, open the terminal and run the following command:
ios-webkit-debug-proxy -c : 27753
To verify in browser by http://localhost:9221

Real Device Configuration
Enable UI Automation (Settings > Developer)

Code Configuration
-Create Java Project Java Class
-Add Selenium webdriver jar & Appium java client in build path

AppiumDriver driver;

DesiredCapabilities capabilities = new DesiredCapabilities ();

capabilities.setCapability (MobileCapabilityType.PLATFORM_NAME, “iOS”);
capabilities.setCapability (MobileCapabilityType.PLATFORM_VERSION, “11.2”);
capabilities.setCapability (MobileCapabilityType.BROWSER_NAME, “Safari”);
capabilities.setCapability (MobileCapabilityType.DEVICE_NAME, “iPhone 6s”);
capabilities.setCapability (MobileCapabilityType.UDID, <>);
capabilities.setCapability (MobileCapabilityType.AUTOMATION_NAME, “XCUITest”);

driver = new IOSDriver (new URL (“http://127.0.0.1:4723/wd/hub”), capabilities);

driver.manage ().timeouts ().implicitlyWait (15, TimeUnit.SECONDS);

driver.get (“https://google.com”);

driver.quit();

Please let me know if you face any issues… Happy Testing.

Thanks,
@2sharKsagar


#2

Hi @2sharKsagar, I mainly face issue with creating a proper xcode certificate/code sign for installing SafariLauncher on device. if you can elaborate that process will be eternally greaful :slight_smile: cheers!