简体   繁体   中英

When starting appium server programmatically using java in eclipse taking too much time

I'm using the following code to start the Appium server:

AppiumDriverLocalService appiumService = AppiumDriverLocalService.buildDefaultService();
appiumService.start();

The problem:

It's taking approx 3 mins to start the server.

I am using appium 1.8.0-beta5

You can use below code for starting appium server programmatically which will take less than 3 minutes :

// start appium server
                Runtime.getRuntime().exec("cmd.exe /c start cmd.exe /k \"appium -a 0.0.0.0 -p 4723\"");
                //get address of appium server
                URL u=new URL("http://0.0.0.0:4723/wd/hub");
                //provide device and app info
                DesiredCapabilities dc=new DesiredCapabilities();
                dc.setCapability(CapabilityType.BROWSER_NAME,"");
                dc.setCapability("deviceName","yh8uujujfhuh");
                dc.setCapability("platformName","android");
                dc.setCapability("platformVersion","6.0");
                dc.setCapability("appPackage","com.google.android.apps.maps");
                dc.setCapability("appActivity","com.google.android.maps.MapsActivity");
                //create driver object to launch app in device
                AndroidDriver driver;
                while(2>1) 
                {
                    try
                    {
                        driver=new AndroidDriver(u,dc);
                        break;//terminate from loop
                    }
                    catch(Exception e)
                    {
                        System.out.println(e.getMessage());
                    }
                }

AppiumDriverLocalService appiumService = AppiumDriverLocalService.buildDefaultService(); appiumService.start();

will work fast if appium version is 1.8.0 not 1.8.0-beta5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM