Skip to content

Instantly share code, notes, and snippets.

@Ununnilium
Last active April 11, 2018 06:03
Show Gist options
  • Save Ununnilium/dc98c42f0417e65761634817128d40b4 to your computer and use it in GitHub Desktop.
Save Ununnilium/dc98c42f0417e65761634817128d40b4 to your computer and use it in GitHub Desktop.

Test a web site with Selenium on a virtual iOS device

  1. Install Xcode (AppStore)
  2. Open Xcode settings download there an iOS image >= 9.3 (older versions need an other setup which is not described here)
  3. Install brew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  4. Execute sudo xcode-select --switch /Applications/Xcode.app
  5. (sudo DevToolsSecurity -enable [probably not necessary])
  6. brew install node carthage
  7. npm install -g appium appium-doctor
  8. (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])
  9. Check if appium works with appium-doctor --ios
  10. Download and install Java JRE or JDK
  11. Download Selenium standalone server from https://www.seleniumhq.org/download/
  12. Start the standalone server as hub with java -jar selenium-server-standalone-3.11.0.jar -role hub
  13. 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": {}
}
  1. Create a Simulator link ln -s /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app /Applications/Simulator.app and start it
  2. Start Appium appium --nodeconfig appium.json
  3. Open now in a Webbrowser http://127.0.0.1:4444/grid/console# to check if Appium was correctly registered at the hub
  4. 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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment