使用Appium

时间:2017-03-28 10:35:08

标签: appium

我使用Appium自动化Android应用程序。我在使用AndroidDriver()时遇到异常。 以下是代码段。

  public class Test1 {

public static AndroidDriver driver;

public static void main(String[] args) throws Exception {

    File appDir= new File(System.getProperty("user.dir")+"/app/");

    System.out.println(appDir);

    File app=new File(appDir,"android-debug.apk");

    DesiredCapabilities cap=new DesiredCapabilities();

    cap.setCapability(MobileCapabilityType.APP,app.getAbsolutePath());

    cap.setCapability(MobileCapabilityType.PLATFORM,MobilePlatform.ANDROID);

    cap.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");

    cap.setCapability(MobileCapabilityType.DEVICE_NAME,"My Phone");

    cap.setCapability(MobileCapabilityType.VERSION,"5.0.2");

    cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,"com.ionicframework.appsix821050" );

    cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,"com.ionicframework.appsix821050.MainActivity" );

    URL url=new URL("http:127.0.0.1:4723/wd/hub");

    try
    {
    driver = new AndroidDriver(url, cap);
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }

}

}

以下是运行上述代码时发现的错误

  

org.openqa.selenium.remote.UnreachableBrowserException:不能   开始一个新的会议。可能的原因是遥控器的无效地址   服务器或浏览器启动失败。       构建信息:版本:'2.39.0',修订版:'14fa800511cc5d66d426e08b0b2ab926c7ed7398',时间:'2013-12-16   十三时18' 分38秒       系统信息:主机:'Mindpro1-PC',ip:'192.168.0.103',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:   '1.8.0_112'       驱动程序信息:driver.version:AndroidDriver         在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)         在org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)         在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:111)         在org.openqa.selenium.remote.RemoteWebDriver。(RemoteWebDriver.java:129)         在org.openqa.selenium.android.AndroidDriver。(AndroidDriver.java:89)         在Test1.main(Test1.java:52)       引起:org.apache.http.client.ClientProtocolException         at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:888)         在org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)         在org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)         在org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:319)         在org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:298)         在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)         ......还有5个       引起:org.apache.http.HttpException:无法将主机转换为URI:http://         在org.apache.http.impl.conn.ProxySelectorRoutePlanner.determineProxy(ProxySelectorRoutePlanner.java:185)         at org.apache.http.impl.conn.ProxySelectorRoutePlanner.determineRoute(ProxySelectorRoutePlanner.java:139)         at org.apache.http.impl.client.DefaultRequestDirector.determineRoute(DefaultRequestDirector.java:763)         at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:382)         在org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:884)         ......还有10个       引起:java.net.URISyntaxException:索引7处的预期权限:http://         在java.net.URI $ Parser.fail(未知来源)         at java.net.URI $ Parser.failExpecting(Unknown Source)         at java.net.URI $ Parser.parseHierarchical(Unknown Source)         在java.net.URI $ Parser.parse(未知来源)         在java.net.URI。(未知来源)         at org.apache.http.impl.conn.ProxySelectorRoutePlanner.determineProxy(ProxySelectorRoutePlanner.java:183)         ... 14更多`

0 个答案:

没有答案