info: Zip-aligning D:\work\workspace\AppiumDemo\src\com\saucelabs\appium\GZ96333Msg.apk
info: Checking whether zipalign is present
info: Stopping logcat capture
debug: Logcat terminated with code null, signal SIGTERM
info: Sent shutdown command, waiting for UiAutomator to stop...
warn: UiAutomator did not shut down fast enough, calling it gone
info: Cleaning up android objects
info: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Could not find zipalign; do you have the Android SDK installed and the tools + platform-tool
s folders added to your PATH?
info: Error: Could not find zipalign; do you have the Android SDK installed and the tools + platform-tools folders added to your PATH?
at null. (C:\Users\jianghong\AppData\Roaming\npm\node_modules\appium\lib\devices\android\adb.js:112:12)
at ChildProcess.exithandler (child_process.js:651:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
info: Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not find zipalign;
do you have the Android SDK installed and the tools + platform-tools folders added to your PATH?)","origValue":"Could not find zipalign; do you have t
he Android SDK installed and the tools + platform-tools folders added to your PATH?"},"sessionId":null}
POST /wd/hub/session 500 10161ms - 392b

代码:
public class AndroidTest {

private AppiumDriver driver;

@Before
public void setUp() throws Exception {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "../AppiumDemo/src/com/saucelabs/appium/");
File app = new File(appDir, "GZ96333Msg.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName","emulator-5554");
capabilities.setCapability("platformVersion", "4.3");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.pactera.gz96333msg");
capabilities.setCapability("appActivity", "com.pactera.gz96333msg.ui.LoginActivity");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}

@After
public void tearDown() throws Exception {
driver.quit();
}

@Test
public void apiDemo(){
WebElement el = driver.findElement(By.name("Animation"));
assertEquals("Animation", el.getText());
el = driver.findElementByClassName("android.widget.TextView");
assertEquals("API Demos", el.getText());
el = driver.findElement(By.name("App"));
el.click();
List els = driver.findElementsByClassName("android.widget.TextView");
assertEquals("Activity", els.get(2).getText());
}

}


↙↙↙阅读原文可查看相关链接,并与作者交流