org.apache.http.conn.HttpHostConnectException:连接到127.0.0.1:4723 [/127.0.0.1]失败:连接被拒绝:连接

时间:2017-05-28 08:59:28

标签: appium

public class Mobiletest {
    private static AndroidDriver driver;

    public static void main(String[] args) throws MalformedURLException,
            InterruptedException {

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("deviceName", "Redmi 1s");
        capabilities.setCapability("platformVersion", "4.4.4");
        capabilities.setCapability("platformName", "Android");
        // capabilities.setCapability("app", app.getAbsolutePath());
        capabilities.setCapability("appPackage",
                "com.zipgo.customer");
        capabilities.setCapability("appActivity",
                "SplashActivity");

        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
                capabilities);          

        // driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
    }

如果出现错误,它会给出错误

  

线程中的异常" main" org.openqa.selenium.WebDriverException:org.apache.http.conn.HttpHostConnectException:连接到127.0.0.1:4723 [/127.0.0.1]失败:连接被拒绝:连接   构建信息:版本:'未知',修订版:'未知',时间:'未知'   系统信息:主持人:' INSPIRON',ip:' 192.168.1.35',os.name:' Windows 8.1',os.arch:&#39 ; amd64',os.version:' 6.3',java.version:' 1.8.0_40'   驱动程序信息:driver.version:AndroidDriver

2 个答案:

答案 0 :(得分:0)

你有多个appium实例在运行吗?如果没有尝试将端口从4723更改为其他内容。

答案 1 :(得分:0)

enter image description here

首先在appium UI中

然后在代码中

 driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
            capabilities);  

就像你的示例代码

一样