Friday, January 31, 2014

Inspecting IOS elements and recording tests using Appium on Simulator

1.Download & Install the GUI version of Appium server(check appium.io)
2.Open the Appium server. You should see some thing like below




















3. We would be inspecting the IOS element using this GUI version of appium
4. Check the flag AppPath an provide the path to your .app(you can find the path from Xcode)
Ex: The path I provided here is '/Users/kiran/Library/Developer/Xcode/DerivedData/UICatalog-fqsvdhmisheuvqbsuomezsujnqgi/Build/Products/Debug-iphonesimulator/UICatalog.app'
5.Ensure you pick the .app path which is in 'Debug-iphonesimulator' folder and not 'Debug-iphoneos folder (when you run the UICatalog code on a real device from Xcode, the .app will be created in 'Debug-iphoneos).
6.Now click on 'Launch' button to start the appium server.
7.Click on 'i' button to launch the IOS inspector
8.Check the below video to see how to inspect elements on IOS simulator and record the tests

You can even play back  the tests with in the appium recorder
Check the following video link to have a glance on how to inspect and record
https://www.youtube.com/watch?v=BNgFixhS_AM&feature=youtu.be

You can run your tests either starting the appium from GUI mode or from terminal mode.
Now lets c how to run the tests when appium is launched from terminal
Stop the GUI mode appium server
open the terminal and type the command appium &. This will launch the appium server on default port 4723


15 comments:

  1. Great article.
    If you would like, I can also publish your article/ or next technical articles at http://www.QATestingTools.com

    ReplyDelete
  2. Excellent Article.
    The video says it is private. Could you share it as well. Thanks!

    ReplyDelete
  3. Vidha, you may check the video now. I made it public

    ReplyDelete
  4. Hi Kiran,
    Seems like you are an expert in mobile testing. I am new to mobile testing and was seeking your help.
    I've spend 3 days searching the net. Yes. I have found lots of info. But its not clear to me yet if I can use laptop running Windows with Appium to test an app in my iPad. I have a feeling I can't. When I start the Appium in GUI mode, there is no way I can specify the UDID and the bundleID of the app.
    Please help
    Thanks

    ReplyDelete
  5. You can run Appium IOS tests only on MAC laptop. Once you install appium on IOS you can see the UDID and bundle id

    ReplyDelete
  6. Hi Kiran,

    Can you please post the instructions on how to install Appium on mac, as when I followed appium.git I couldn't able to invoke iphone simulator and neither UDID and bundle id are prepopulating on Appium GUI

    ReplyDelete
    Replies
    1. Vishal, You can check my subsequent blogs

      http://iosautomation.blogspot.in/2013/12/setting-up-appium-server.html

      Try this setup and let me know in case of any issues

      Delete
  7. Hi Kiran !

    Can you please help me setup Appium in mac os, i have try with blogs http://iosautomation.blogspot.in/2013/12/setting-up-appium-server.html
    but appium not run. it have bug:
    error: The following desired capabilities are required, but were not provided: deviceName

    info: <-- POST /wd/hub/session 500 27.454 ms - 286

    error: Failed to start an Appium session, err was: Error: The following desired capabilities are required, but were not provided: deviceName

    ReplyDelete
    Replies
    1. Send me the complete server log and the webdriver code where you had configured the capabilities and send me the screen shot of your Appium GUI capabilities

      Delete
    2. hi Kiran , you can see log:

      info: Welcome to Appium v1.3.1 (REV 1160ce02bb89c354cb99317985123acf39f0e7d3)

      info: Appium REST http interface listener started on 127.0.0.1:4723

      info: [debug] Non-default server args: {"app":"/Users/admin/Desktop/WordPress 4.4.ipa","address":"127.0.0.1","callbackAddress":"127.0.0.1","callbackPort":4723,"deviceName":"iPhone 4s","defaultCommandTimeout":7200}

      info: Console LogLevel: debug

      info: --> GET /wd/hub/status {}

      info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.3.1","revision":"1160ce02bb89c354cb99317985123acf39f0e7d3"}}}

      info: <-- GET /wd/hub/status 200 12.305 ms - 104 {"status":0,"value":{"build":{"version":"1.3.1","revision":"1160ce02bb89c354cb99317985123acf39f0e7d3"}}}

      info: --> GET /wd/hub/sessions {}

      info: [debug] Responding to client with success: {"status":0,"value":[]}

      info: <-- GET /wd/hub/sessions 200 2.330 ms - 23 {"status":0,"value":[]}

      info: --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"iOS","platformVersion":"7.1","newCommandTimeout":"999999","automationName":"Appium","deviceName":"iPhone 4s"}}

      info: Client User-Agent string: Appium (unknown version) CFNetwork/673.5 Darwin/13.4.0 (x86_64) (MacPro6%2C1)

      info: [debug] Using local .ipa from command line: /Users/admin/Desktop/WordPress 4.4.ipa
      info: [debug] Copying local zip to tmp dir

      info: [debug] /Users/admin/Desktop/WordPress 4.4.ipa copied to /var/folders/zr/7wd1_hld0kb585c0dc_j4g2c0000gn/T/114103-604-9gife0/appium-app.zip

      info: [debug] Unzipping /var/folders/zr/7wd1_hld0kb585c0dc_j4g2c0000gn/T/114103-604-9gife0/appium-app.zip

      info: [debug] Testing zip archive: /var/folders/zr/7wd1_hld0kb585c0dc_j4g2c0000gn/T/114103-604-9gife0/appium-app.zip

      info: [debug] Zip archive tested clean

      info: [debug] Unzip successful

      info: [debug] Using locally extracted app: /var/folders/zr/7wd1_hld0kb585c0dc_j4g2c0000gn/T/114103-604-9gife0/Payload/WordPress.app

      info: [debug] Creating new appium session 58dfe0ae-2b50-4470-93e6-124649acc19f
      info: [debug] Removing any remaining instruments sockets

      info: [debug] Cleaned up instruments socket /tmp/instruments_sock
      info: [debug] Setting Xcode folder

      info: [debug] Setting Xcode version

      info: [debug] Setting iOS SDK Version

      info: [debug] Getting sdk version from xcrun with a timeout

      info: [debug] iOS SDK Version set to 8.1

      info: [debug] Checking whether instruments supports our device string
      info: [debug] Getting list of devices instruments supports

      info: [debug] Instruments is at: /Applications/Xcode 2.app/Contents/Developer/usr/bin/instruments

      info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.1","iOSSDKVersion":"8.1","deviceName":"iPhone 4s","platformVersion":"7.1"}

      info: [debug] fixDevice is on
      info: [debug] Final device string is: 'iPhone 4s (7.1 Simulator)'
      info: [debug] iOS sim UDID is 36A04A6D-DC5F-4AAD-AC7E-A9FF8A70964D
      info: [debug] Detecting automation tracetemplate

      info: [debug] Not auto-detecting udid, running on sim

      info: [debug] Parsed app Info.plist (as binary)

      info: [debug] Parsed app Localizable.strings
      info: [debug] Getting bundle ID from app

      info: [debug] Parsed app Info.plist (as binary)
      info: [debug] Creating instruments
      info: On some xcode 6 platforms, instruments-without-delay does not work. If you experience this, you will need to re-run appium with the --native-instruments-lib flag
      info: [debug] Preparing uiauto bootstrap
      info: [debug] Dynamic bootstrap dir: /Users/admin/Library/Application Support/appium/bootstrap

      Delete
    3. info: [debug] Dynamic env: {"nodePath":"/Applications/Appium.app/Contents/Resources/node/bin/node","commandProxyClientPath":"/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/bin/command-proxy-client.js","instrumentsSock":"/tmp/instruments_sock","interKeyDelay":null,"justLoopInfinitely":false,"autoAcceptAlerts":false}

      info: [debug] Dynamic bootstrap code: // This file is automatically generated. Do not manually modify!
      ...
      info: [debug] Dynamic bootstrap path: /Users/admin/Library/Application Support/appium/bootstrap/bootstrap-60f23230385b0cfa.js

      info: [debug] Getting device string from opts: {"forceIphone":false,"forceIpad":false,"xcodeVersion":"6.1","iOSSDKVersion":"8.1","deviceName":"iPhone 4s","platformVersion":"7.1"}
      info: [debug] fixDevice is on
      info: [debug] Final device string is: 'iPhone 4s (7.1 Simulator)'

      info: [debug] We're on iOS7.1+ so forcing defaultDevice on

      info: [debug] Parsed app Info.plist (as binary)

      info: [debug] Wrote new app Info.plist with device type

      info: [debug] Checking whether we need to set app preferences
      info: [debug] Running ios sim reset flow
      info: [debug] Killing the simulator process
      info: [debug] Killall iOS Simulator

      info: [debug] Killing any other simulator daemons

      info: [debug] Cleaning sim data files

      info: [debug] Executing: xcrun simctl erase 36A04A6D-DC5F-4AAD-AC7E-A9FF8A70964D

      info: [debug] Cleaning app data files

      error: Could not reset simulator. Leaving as is. Error: Command failed: // stderr:

      info: [debug] Deleting /Users/admin/Library/Developer/CoreSimulator/Devices/36A04A6D-DC5F-4AAD-AC7E-A9FF8A70964D/data/Applications/649A0FC6-9BE1-4F78-893C-152FCEFE7759

      info: [debug] Not setting locale

      info: [debug] No iOS / app preferences to set
      info: [debug] Starting iOS 8.* simulator log capture

      info: [debug] Not pre-launching simulator

      info: [debug] No device id or app, not installing to real device.

      info: [debug] Starting command proxy.
      info: [debug] Instruments socket server started at /tmp/instruments_sock
      info: [debug] Starting instruments

      info: [debug] Instruments is at: /Applications/Xcode 2.app/Contents/Developer/usr/bin/instruments

      info: Launching instruments

      info: [debug] Attempting to run app on iPhone 4s (7.1 Simulator)
      info: [debug] Spawning instruments with command: "/Applications/Xcode 2.app/Contents/Developer/usr/bin/instruments" -t "/Applications/Xcode 2.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.xrplugin/Contents/Resources/Automation.tracetemplate" -D /tmp/appium-instruments/instrumentscli0.trace -w "iPhone 4s (7.1 Simulator)" /var/folders/zr/7wd1_hld0kb585c0dc_j4g2c0000gn/T/114103-604-9gife0/Payload/WordPress.app -e UIASCRIPT "/Users/admin/Library/Application Support/appium/bootstrap/bootstrap-60f23230385b0cfa.js" -e UIARESULTSPATH /tmp/appium-instruments
      info: [debug] And extra without-delay env: {"DYLD_INSERT_LIBRARIES":"/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6/InstrumentsShim.dylib","LIB_PATH":"/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd6"}
      info: [debug] And launch timeouts (in ms): {"global":90000}

      Delete
    4. info: [debug] [INST] Waiting for device to boot...

      info: --> GET /wd/hub/status {}

      info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.3.1","revision":"1160ce02bb89c354cb99317985123acf39f0e7d3"},"isShuttingDown":false},"sessionId":"58dfe0ae-2b50-4470-93e6-124649acc19f"}

      info: <-- GET /wd/hub/status 200 3.040 ms - 178 {"status":0,"value":{"build":{"version":"1.3.1","revision":"1160ce02bb89c354cb99317985123acf39f0e7d3"},"isShuttingDown":false},"sessionId":"58dfe0ae-2b50-4470-93e6-124649acc19f"}

      Delete
    5. and see image at here: http://i.imgur.com/YcLGJCp.png

      Delete
  8. Thanks you for the awesome information in your blog on  Appium

    ReplyDelete
  9. Thanks you for the awesome information in your blog on  Appium

    ReplyDelete