我是appium的新手。当我在eclipse中运行appium代码时,我遇到了以下错误:
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{app=D:\Workspace\Mobile\Apps\ATT\AT.apk, appPackage=com.atp.android, appActivity=Splash, appium-version=1.6.4, platformVersion=6.0, platformName=Android, deviceName=Test}], required capabilities = Capabilities [{}]
代码:
private static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
AppiumDriver driver;
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/Apps/AST/");
File app = new File(appDir, "AT.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("appium-version", "1.6.4");
//capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "Test");
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.atp.android");
capabilities.setCapability("appActivity", "Splash");
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();
Selenium版本是3.4 请帮助解决此问题。感谢
答案 0 :(得分:0)
您可以尝试评论以下两行,看看它是如何工作的:
capabilities.setCapability("appPackage", "com.atp.android");
capabilities.setCapability("appActivity", "Splash");
因为当您在复杂的应用程序上运行测试时,很难确保apppackage和app的内容设置正确。 Appium会帮助您自动找到正确的内容。