【问题标题】:In Mobile App automation, Eclipse displayed error "Unable to create new remote session."在移动应用自动化中,Eclipse 显示错误“无法创建新的远程会话”。
【发布时间】:2017-09-15 12:50:55
【问题描述】:

在移动应用自动化中,Eclipse 显示错误“无法创建新的远程会话。”

这是我的代码:

public class MyFirstAppiumClass {

    AppiumDriver<WebElement> driver;

    @BeforeClass
    public void setup() throws MalformedURLException
    {               
        DesiredCapabilities cap = new DesiredCapabilities();
        //cap.setCapability("BROWSER_NAME", "Android");
        cap.setCapability("platformVersion","6.0.1");
        cap.setCapability("deviceName","Nexus 5");
        cap.setCapability("platformName","Android");
        cap.setCapability("appPackage", "com.android.calculator2");
        cap.setCapability("appActivity", "com.android.calculator2.Calculator");
        driver = new AndroidDriver<WebElement> (new URL("http://0.0.0.0:4723/wd/hub"),cap);
    }

    @Test
    public void testCal() throws Exception
    {
        WebElement two = driver.findElement(By.name("4"));
        two.click();
        WebElement plus = driver.findElement(By.name("+"));
        plus.click();
        WebElement four = driver.findElement(By.name("4"));
        four.click();
        WebElement equalto = driver.findElement(By.name("="));
        equalto.click();
        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
        WebElement results = driver.findElement(By.tagName("EditText"));
        assert results.getText().equals("8"):"Actual Value is : "+results.getText()+" did not match with expected value: 8";
    }

}

这是错误:

org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session.
desired capabilities = Capabilities [{appPackage=com.android.calculator2, appActivity=com.android.calculator2.Calculator, platformVersion=6.0.1, platformName=Android, deviceName=Nexus 5}], required capabilities = Capabilities [{}]

【问题讨论】:

  • 你在开始运行代码之前是否手动启动了appium server?

标签: android eclipse mobile automation appium


【解决方案1】:

您可以尝试更改以下行吗:

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

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

【讨论】:

  • 不,它对我不起作用。显示相同的问题。
  • 谢谢它帮助了我。
猜你喜欢
  • 2020-06-15
  • 1970-01-01
  • 2017-03-03
  • 2016-03-27
  • 2019-10-14
  • 2017-09-10
  • 2017-05-26
  • 2021-04-05
  • 2017-06-26
相关资源
最近更新 更多