【问题标题】:Not able to connect/run a operation on android device in android studio无法在 android studio 中的 android 设备上连接/运行操作
【发布时间】:2017-02-19 19:56:30
【问题描述】:

我无法从 android studio 在真正的 android 设备上连接或运行脚本,并出现以下错误:

代码如下: 导入 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 设备监视器中列出

并在cmd中显示连接

我尝试的方法是更改​​以下设置:

  • Android studio > 运行 > 编辑配置 > 在常规选项卡中 > 将目标设置为 USB 设备。

知道什么是错的

【问题讨论】:

    标签: android selenium android-studio automation appium


    【解决方案1】:

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

    【讨论】:

    • 没有尝试过,甚至尝试将新的 .apk 放在那里。结果相同
    • 我认为有另一个应用程序具有相同的文件。这可能是问题所在。
    猜你喜欢
    • 2015-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-07
    • 1970-01-01
    相关资源
    最近更新 更多