在移动应用程序自动化中,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 [{}]
答案 0 :(得分:0)
您可以尝试更改以下行:
driver = new AndroidDriver(新网址(&#34; http://0.0.0.0:4723/wd/hub&#34;),上限);
到
driver = new AndroidDriver(新网址(&#34; http://127.0.0.1:4723/wd/hub&#34;),上限);