Appium 我运行自动化脚本时报错,不知道是什么原因大家帮忙看看

豆豆 · 2014年06月11日 · 最后由 隔壁小王 回复于 2015年08月03日 · 1127 次阅读

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());
}

}

共收到 4 条回复 时间 点赞

http://testerhome.com/topics/773 遇到问题先尝试论坛关键字搜索

#1 楼 @tom_ma@jh_soft 这个问题今天刚有人问过

GZ96333Msg.apk
找不到

报错很显然了:你确认已经安装了 Android SDK 并将 SDK 中相关的工具文件夹设置环境变量了吗?

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册