I used SauceLabs example
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("BROWSER_NAME", "Android");
capabilities.setCapability("VERSION", "4.4.2");
capabilities.setCapability("deviceName", "Android Emulator");
capabilities.setCapability("platformName", "Android");
//zip file containing your app to be tested
capabilities.setCapability("app", "http://appium.s3.amazonaws.com/TestApp6.0.app.zip");
driver = new RemoteWebDriver
(new URL(MessageFormat.format("http://{0}:{1}@ondemand.saucelabs.com:80/wd/hub",
sauceUserName, sauceAccessKey)), capabilities);
And this is work perfectly fine. But when I downloaded zip with app and switched to local environment
capabilities.setCapability("app", app.getAbsolutePath());
driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
I got error from appium console:
error: Failed to start an Appium session, err was: Error: Bad app: /home/.../appium/assets/TestApp6.0.app.zip. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: App zip unzipped OK, but we couldn't find a .app bundle in it. Make sure your archive contains the .app package and nothing else
Try this instead of RemoteWebDriver
: use AndroidDriver
.
Also, if you run from localhost
mention the IP address or just type "localhost"
.
capabilities.setCapability("app", app.getAbsolutePath());
driver = new AndroidDriver (new URL("http://localhost:4723/wd/hub"), capabilities);
Create a folder called "app"
and place your testing Android app there.
Example code:
File filePath = new File(System.getProperty("user.dir"));
File appDir = new File(filePath, "/app");
File app = new File(appDir, "yourapkfile.apk");