Test a web site with Selenium on a virtual iOS device
Install Xcode (AppStore)
Open Xcode settings download there an iOS image >= 9.3 (older versions need an other setup which is not described here)
Install brew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Execute sudo xcode-select --switch /Applications/Xcode.app
(sudo DevToolsSecurity -enable
[probably not necessary])
brew install node carthage
npm install -g appium appium-doctor
(Install Appium desktop version (appium-desktop-x.x.x.dmg) from https://github.com/appium/appium-desktop/releases/tag/v1.4.1 [probably not necessary])
Check if appium works with appium-doctor --ios
Download and install Java JRE or JDK
Download Selenium standalone server from https://www.seleniumhq.org/download/
Start the standalone server as hub with java -jar selenium-server-standalone-3.11.0.jar -role hub
Create the following Appium config appium.json
:
{
"capabilities" : [
{
"platformName" : " ios" ,
"platformVersion" : " 9.3" ,
"browserName" : " safari" ,
"deviceName" : " iPhone 4s" ,
"automationName" : " XCUITest" ,
"maxInstances" : 1 ,
"seleniumProtocol" : " WebDriver"
}
],
"proxy" : " org.openqa.grid.selenium.proxy.DefaultRemoteProxy" ,
"url" : " http://127.0.0.1:4723/wd/hub" ,
"host" : " 127.0.0.1" ,
"port" : 4723 ,
"maxSession" : 5 ,
"register" : true ,
"registerCycle" : 5000 ,
"role" : " node" ,
"hub" : " http://127.0.0.1:4444" ,
"hubPort" : 4444 ,
"hubHost" : " 127.0.0.1" ,
"debug" : false ,
"servlets" : [],
"withoutServlets" : [],
"custom" : {}
}
Create a Simulator link ln -s /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app /Applications/Simulator.app
and start it
Start Appium appium --nodeconfig appium.json
Open now in a Webbrowser http://127.0.0.1:4444/grid/console# to check if Appium was correctly registered at the hub
Test now connection from Python (with Selenium installed):
from selenium import webdriver
cap = {
'platformName' : 'ios' ,
'platformVersion' : '9.3' ,
'browserName' : 'safari' ,
'deviceName' : 'iPhone 4s' ,
'automationName' : "XCUITest"
}
driver_ios = webdriver .Remote (command_executor = 'http://127.0.0.1:4444/wd/hub' , desired_capabilities = cap )
driver_ios .get ("https://www.google.com" )
driver_ios .quit ()