错误:无法找到或加载主类Amazon.StartApplication

时间:2016-01-28 08:53:27

标签: java selenium appium

新手查询,我已经为appium正确地包含了路径/ jar,但是在调试过程中似乎仍然遇到上述错误。还看到了无法访问的浏览器异常w.r.t AndroidDriver。任何帮助表示赞赏。

package amazon;

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, "/Apps/Amazon/");
            File app = new File(appDir, "in.amazon.mShop.android.shopping.apk");

            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
            capabilities.setCapability("deviceName", "Micromax A311");
            capabilities.setCapability("platformVersion", "4.4.2");
            capabilities.setCapability("platformName", "Android");
            capabilities.setCapability("app", app.getAbsolutePath());
            capabilities.setCapability("appPackage", "in.amazon.mShop.android.shopping");
            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();

    }

}

1 个答案:

答案 0 :(得分:0)

试试这个

public class StartApplication {

        private static AndroidDriver driver=null;
        DesiredCapabilities capabilities = new DesiredCapabilities();
        public static void main(String[] args) throws MalformedURLException, InterruptedException {

            File classpathRoot = new File(System.getProperty("user.dir"));
            File appDir = new File(classpathRoot, "/Apps/Amazon/");
            File app = new File(appDir, "in.amazon.mShop.android.shopping.apk");

            DesiredCapabilities capabilities = new DesiredCapabilities();
            capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
            capabilities.setCapability("deviceName", "Micromax A311");
            capabilities.setCapability("platformVersion", "4.4.2");
            capabilities.setCapability("platformName", "Android");
            capabilities.setCapability("app", app.getAbsolutePath());
            capabilities.setCapability("appPackage", "in.amazon.mShop.android.shopping");
            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();
}