无法在android studio

时间:2016-10-11 09:41:39

标签: android selenium android-studio automation appium

我无法在Android工作室的真实Android设备上连接或运行脚本,并且出现以下错误:

enter image description here

代码如下:     import org.junit.Before;

import java.net.URL;

import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import io.appium.java_client.android.AndroidDriver;

public class Sample {

    private static RemoteWebDriver driver;
    @Before
    public void setUp() throws Exception {
        DesiredCapabilities  capabilities = new DesiredCapabilities();
        capabilities.setCapability("device","Android");
        capabilities.setCapability("app", "Chrome");
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability(CapabilityType.VERSION, "4.4.2");
        capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");
        driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),
                capabilities);
    }

    @Test
    public void testcase_001() throws Exception{
        driver.get("http://www.google.com");

        WebElement keyword = driver.findElementByName("q");
        keyword.sendKeys("appium");
        driver.findElement(By.id("btnK")).click();
        Thread.sleep(5000);
    }
}

但该设备列在Android设备监视器

enter image description here

显示连接在cmd

enter image description here

我尝试过的事情正在改变以下设置:

  • Android studio>运行>编辑配置>在Gerenal标签中>将Target设置为USB DEVICE。

任何想法出了什么问题

1 个答案:

答案 0 :(得分:0)

如果您之前已经安装过,请删除最后一个apk并尝试安装新的apk。