我是appium自动化测试的新手,我尝试使用appium和java运行代码集,但是尽管我安装了最新版本的appium和nodejs,但我总是在以下代码下运行此错误,但始终会返回此错误。
我尝试在Windows 10上使用appium 1.13.0运行以下代码,并且已经安装了所有必备组件,例如node js和appium桌面客户端
package andriod;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class StartApplication {
private static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/Apps/");
File app = new File(appDir, "in.amazon.mShop.android.shopping_2019-09-11.apk");
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("autoGrantPermissions", true);
caps.setCapability("noReset", true);
caps.setCapability(CapabilityType.BROWSER_NAME, "");
caps.setCapability(MobileCapabilityType.DEVICE_NAME,"Redmi");
caps.setCapability(CapabilityType.PLATFORM_NAME, "ANDROID");
caps.setCapability(CapabilityType.VERSION, "9.0");
caps.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT,"60");
caps.setCapability("app", app.getAbsolutePath());
caps.setCapability("appPackage", "in.amazon.mShop.android.shopping");
caps.setCapability("appActivity", "com.amazon.mShop.home.HomeActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), caps);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
Thread.sleep(10000);
driver.quit();
}
}
我希望代码可以成功运行,但错误消息如下所示返回给我
原始错误:'命令'C:\ Users \ myusername \ AppData \ Local \ Android \ sdk \ platform-tools \ adb.exe -P 5037 -s dd8fa21 shell pm install -g / data / local / tmp / appium_cache / 728413456b86856a2003edeb524d6bd577ca6418。 apk'以代码1'退出;斯特德:'';代码:“ 1”
最佳答案
问题出在命令本身,可能是appium@beta
尚未配置。
如果尝试自行运行命令:adb -P 5037 -s dd8fa21 shell pm install -g /data/local/tmp/appium_cache/728413456b86856a2003edeb524d6bd577ca6418.apk
您将看到输出说:Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
appium espresso服务器生成的命令中缺少测试标志-t
。
我通过手动安装运行apk解决了它:adb -P 5037 -s dd8fa21 shell pm install -t -g /data/local/tmp/appium_cache/728413456b86856a2003edeb524d6bd577ca6418.apk
关于java - 如何解决“原始错误:'命令'以代码1退出”;斯特德:'';代码:'1'',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57929315/