Mobile Automation Testing using APPIUM, Selenium Webdriver and Java(IOS)

All things mentioned below is considering IOS 10.
Prerequisite
1)Download and Install JavaDownload here
2)Download and Install eclipseDownload here
3)Download and Install xcode Download here
4)Download and Install xcode via Terminal "xcode-select --install"
5)Download and Install Appium Java Client Lib(jar)Download here
6)Download and Install Selenium Webdriver(selenium-server-standalone-3.0.0-beta2.jar)Download here
7)Download and Install APPIUM for IOS(appium-1.4.13.dmg)(Note latest appium dmg file has some problem)Download here
8)Download and Install command line tools for xcode via Terminal "xcode-select –install "

For TestNG:
  Start eclipse->Help->Install New Software->Works With
     Name:- TestNG
     Location:-Update site for release: http://beust.com/eclipse.
                         Or
     Update site for beta: http://testng.org/eclipse-beta
  Tick checkboxes and follow steps

Start First APPIUM Test for Android Native App
 1)Start Eclipse, Create new java project (File->New->Other->Java Project->Enter Project name
 2)Add Selenium and TestNG Jar( right click on project folder->build Path->Configure build path->Libraries->Add 
 external jars (browse your jar files form computer(java-client-3.2.0 and selenium-server-standalone-3.0.0-beta2 JAR files)
 3)Add TestNG JAR( right click on project folder->build Path->Configure build path->Libraries->Add Library ->select 
 TestNG Lib and follow steps.
 4)Create Java class file(Right Click on Project Folder->New->Class->Enter Package and Class name)
 5) Write following code for first Test Case for App Launch on real IOS device
 Demo Code
        package demo;
        import io.appium.java_client.ios.IOSDriver; 
        import io.appium.java_client.remote.MobileCapabilityType;
        import junit.framework.Assert;
        import java.io.File;
        import java.net.MalformedURLException;
        import java.net.URL;
        import java.util.concurrent.TimeUnit;
        import org.openqa.selenium.By;
        import org.openqa.selenium.WebElement;
        import org.openqa.selenium.remote.DesiredCapabilities;
        import org.testng.annotations.AfterClass;
        import org.testng.annotations.BeforeClass;
        import org.testng.annotations.Test;
        public class LaunchAppon RealDevice 
        {
             IOSDriver driver;
             @BeforeClass
             public void setUp() throws MalformedURLException
             {
             File app=new File("ipa file path");
             DesiredCapabilities caps = new DesiredCapabilities();
             caps.setCapability(MobileCapabilityType.APP,app);
             caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "8.1");
             caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
             caps.setCapability(MobileCapabilityType.DEVICE_NAME,"iPhone 5");      
             driver = new IOSDriver (new URL("http://127.0.0.1:4723/wd/hub"), caps);
             driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
             }
        @Test(priority = 0)
        public void checkAppElementPresent() 
        {
            try{
                  Boolean iselementpresent = driver.findElementsByName("dummytext").size() != 0;
                  Assert.assertTrue(iselementpresent);
                  System.out.println("TC1 :-Elements exist on app");
               } catch(Throwable e)
               {
                  System.out.println("Test Case Failed");
      
               }
         }
  
        @AfterClass
        public void tearDown()
        {
            driver.closeApp();
        } 
  }
 
How to run:
 1) Right click on code area->Run As-> TestNG Test (Before run it start your appium server and connect your device to 
 computer   via usb(make sure device connected))
 You will get result.(To view HTML result , just right click on project folder->refresh and view test-output 
 folder->open index.html file in browser.


For Appium Setting:-Launch Appium server
  Condition 1(If already present into device):
  
  1)Click Android icon->make sure all fields are unchecked 
  2)Click on setting icon-> make sure server address: 127.0.0.1 and Port:4730

  Condition 2(If apk file present into computer):

  1)Click Android icon->Add Applicatipn Path then we will get package and Activity name automatically
  2)Click on setting icon-> make sure server address: 127.0.0.1 and Port:4730

  Click on Launch Button before executes your test script


For Inspect app  Elements use Appium Inspector