无法使用Appium在android应用上执行任何操作

时间:2018-07-21 06:59:16

标签: java appium-android

public class CalculatorTest {

private static AndroidDriver driver;

@Test
public void test() throws MalformedURLException, InterruptedException {
    DesiredCapabilities capabilities = new DesiredCapabilities();


    capabilities.setCapability("deviceName", "Lenovo A7020a48");
    capabilities.setCapability("platformVersion", "6.0");
    capabilities.setCapability("platformName", "Android");
    //capabilities.setCapability("autoGrantPermissions", true); 

    capabilities.setCapability("appPackage", "com.android.calculator2");
    capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");

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

    driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
    Thread.sleep(5000);

    WebElement ele =driver.findElement(By.id("com.android.calculator2:id/digit_4"));
    //.click();
    System.out.println("-------3");
    System.out.println("-------"+ele.getText());
    driver.findElementById("com.android.calculator2:id/op_add").click();

    driver.findElementById("com.android.calculator2:id/digit_4").click();

    driver.findElementById("com.android.calculator2:id/eq").click();


    driver.quit();

}

我在控制台中收到的错误是-

org.openqa.selenium.WebDriverException: java.net.SocketException: Software caused connection abort: recv failed**
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z'
System info: host: 'LAPTOP-DA06FTQB', ip: '192.168.1.5', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: AndroidDriver
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:84)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)

0 个答案:

没有答案