Mobile Automation

Requirements

  • Mac OS X 10.10 or higher
  • XCode >= 8.3.2
  • Apple Developer Tools (iPhone simulator SDK, command line tools)
  • Appium
  • Java latest version

Installing Xcode

  • Navigate to apple software downloads page Apple Downloads
  • Download Xcode and install
  • Download command line tools and install.

Install Java


Appium Installation

  • Install brew
    open command line terminal  in mac  and run the following command
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  • Install Node
    Open the terminal and run the following command
    $ brew install node

  • Install Appium
    npm install g appium@appiumversion
    eg : npm install g appium@1.6.5

  • Check Appium works 
    $appium
    If you install appium successfully you will see the following server log and you are ready start IOS automation.

   
     brew install libimobiledevice --HEAD 
           brew install carthage
     npm install -g ios-deploy


Running Your Test In Real IOS Device

  • You have to have your own .ipa file which is related to your application.
  • You should have the required certificated and provisioning profiles related to the development team.
  • Sample simple test without modularization.



public class OrderLoginTest {
    IOSDriver iosDriver;
    @BeforeClass    
public void setup() throws MalformedURLException {

        iosDriver = getIosDriver();



    }

    @Test    
public void loginToApp() {
           WebElement txtBoxUserName = iosDriver.findElement(By.id("username"));

WebElement txtBoxUserPassword = iosDriver.findElement(By.id("password"));
        txtBoxUserPassword.sendKeys("1111");

        WebElement btnSubmit = iosDriver.findElement(By.id("submit"));
        btnSubmit.click();
    }

    @AfterClass    
public void quiteDrivers(){
        iosDriver.quit()
} public IOSDriver getIosDriver() throws MalformedURLException { DesiredCapabilities capabilities = new DesiredCapabilities(); // mandatory capabilities. capabilities.setCapability(MobileCapabilityType.UDID, DEVICE_UUID); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPad Air"); capabilities.setCapability(MobileCapabilityType.APP, ".ipa file location"); capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "IOS"); capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.3"); capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 60); capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest"); capabilities.setCapability(MobileCapabilityType.SUPPORTS_JAVASCRIPT, true); capabilities.setCapability(MobileCapabilityType.TAKES_SCREENSHOT, true); capabilities.setCapability(MobileCapabilityType.NO_RESET, true); capabilities.setCapability(MobileCapabilityType.AUTO_WEBVIEW, true); capabilities.setCapability(MobileCapabilityType.FULL_RESET, false); capabilities.setCapability(MobileCapabilityType.NO_RESET, true); URL url = new URL("http://0.0.0.0:4723/wd/hub"); IOSDriver iosDriver = new IOSDriver(url,capabilities); return iosDriver; } }


Running Your Test In Real IOS Device Certificates



open the xcode project in the following location and sign it and build it.
/usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent/WebDriverAgent.xcodeproj

Generating Config.xcconfig file to run in real device

1. Open the existing WebDriver Agent .
2. On top of Xcode you File > New> File .
3. Select OSX->.Other-> Select Configuration settings file.
4. Paste the following things in newly created file.
DEVELOPMENT_TEAM = xxxxxxxxx
CODE_SIGN_IDENTITY = iPhone Developer 
Development team is Team ID which your developer should be able to provide . 

How desired capabilities Looks like

 ("xcodeConfigFile", System.getProperty("user.dir") + "/src/main/resources/Config.xcconfig");






 













No comments:

Post a Comment