簡體   English   中英

無法在真實設備上運行appium腳本。 收到錯誤的應用錯誤

[英]Not able to run appium script on real device. getting a bad app error

我試圖在Eclipse,使用Appium和使用USB連接的真實設備中執行此Java代碼。 我無法對設備中安裝的應用的設備進行測試。

    package appiumproject;
    import io.appium.java_client.android.AndroidDriver;
    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;

    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, "/sdcard/Android/data/");
                File app = new File(appDir, "com.alensw.PicFolder");

                DesiredCapabilities capabilities = new DesiredCapabilities();
                capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
                capabilities.setCapability("deviceName", "BX9034M10V");
                capabilities.setCapability("platformVersion", "4.1.2");
                capabilities.setCapability("platformName", "Android");
                capabilities.setCapability("app", app.getAbsolutePath());
                capabilities.setCapability("appPackage", "com.alensw.PicFolder");
                //capabilities.setCapability("appActivity", "com.amazon.mShop.home.HomeActivity");

                driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
                driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
                Thread.sleep(10000);
                driver.quit();

以下是我在Eclipse控制台中遇到的錯誤。 有人可以讓我知道錯誤的原因:“錯誤的應用程序”如何從Android設備上獲取應用程序的classPathRoot,appActivity?
}線程“主”中的異常org.openqa.selenium.SessionNotCreatedException:無法創建新會話。 (原始錯誤:錯誤的應用程序:C:\\ Users \\ admin \\ workspace \\ AppiumProject \\ sdcard \\ Android \\ data \\ com.alensw.PicFolder。應用程序路徑必須是絕對路徑,或相對於appium服務器安裝目錄,或指向原因:錯誤:使用本地應用程序,但未以.zip,.ipa或.apk結尾(警告:服務器未提供任何堆棧跟蹤信息)命令持續時間或超時:0毫秒生成信息:版本:'3.3.1',修訂版本:'5234b32',時間:'2017-03-10 09:04:52 -0800'系統信息:主機:'ADMIN-PC',ip:'10 .0。 0.63',操作系統名稱:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.8.0_121'驅動程序信息:driver.version:sun.reflect上的AndroidDriver。 org.openqa上java.lang.reflect.Constructor.newInstance上的NativeConstructorAccessorImpl.newInstance0(本機方法),sun.reflect.NativeConstructorAccessorImpl.newInstance(未知源),java.lang.reflect.Constructor.newInstance(未知源)。 selenium.remote.ErrorHandle 位於io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:160)的org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)的r.createThrowable(ErrorHandler.java:216) io.appium.java_client.remote.AppiumCommandExecutor.doExecute(AppiumCommandExecutor.java:111)上的io.appium.java_client.remote.AppiumProtocolHandShake.createSession(AppiumProtocolHandShake.java:75)。io.appium.java_client.remote.AppiumCommandExecutor.execute .java:162),位於io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42),位於io.appium.java_client.AppiumDriver的org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)。在org.openqa上的io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)上執行(AppiumDriver.java:1)在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)上.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:1 31)在io.appium.java_client.DefaultGenericMobileDriver。(DefaultGenericMobileDriver.java:38)在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:144)在io.appium.java_client.AppiumDriver。(AppiumDriver.java: 88)在io.appium.java_client.AppiumDriver。(AppiumDriver.java:112)在io.appium.java_client.android.AndroidDriver。(AndroidDriver.java:73)在appiumproject.StartApplication.main(StartApplication.java:29)

    }

在下面的功能中,您需要提及.apk文件的路徑

capabilities.setCapability("app", app.getAbsolutePath());

它應該像下面這樣:

capabilities.setCapability("app","path of apk file");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM