ios-ui-automationappium-ios

Running appium programatically in mac terminal using Java


I want to start appium server programatically in mac using Java.

Can any one help me how to write the code to start appium.

Thanks..


Solution

  • You can launch appium server programmatically with below piece of code.

    appium = AppiumDriverLocalService.buildService(new AppiumServiceBuilder()
                .withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
                .usingPort(4723).withIPAddress("127.0.0.1"));
    appium.start();
    

    If you want to launch from terminal you can run below command

    /Applications/Appium.app/Contents/Resources/node/bin/node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js
    

    If you want to specify the simulator and app details etc you can run below command.

    node /Applications/Appium.app/Contents/Resources/node_modules/appium/bin/appium.js --address 127.0.0.1 --port 4723 --full-reset 
    --device-name "iPhone 6" 
    --platform-name iOS 
    --platform-version "8.3" 
    --app "/My.app"
    --browser-name iOS
    

    For this the node executable should be added to the path.

    For starting appium 1.5.3 go through below link.

    starting appium 1.5.3 programmatically