2

我已经为使用 eclipse 的 Android 应用程序的测试自动化准备了环境。我已按照以下站点的说明进行操作:

https://code.google.com/p/selenium/wiki/AndroidDriver#Setup_the_Environment

我从上述网站复制了以下代码,如下所示:

import junit.framework.TestCase;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.android.AndroidDriver;

public class OneTest extends TestCase {

  public void testGoogle() throws Exception {
    WebDriver driver = new AndroidDriver();

    // And now use this to visit Google
    driver.get("http://www.google.com");

    // Find the text input element by its name
    WebElement element = driver.findElement(By.name("q"));

    // Enter something to search for
    element.sendKeys("Cheese!");

    // Now submit the form. WebDriver will find the form for us from the element
    element.submit();

    // Check the title of the page
    System.out.println("Page title is: " + driver.getTitle());
    driver.quit();
  }
}

但是在以下行中发现了“WebDriver 无法解析为类型”的错误:

WebDriver driver = new AndroidDriver();

WebDriver 无法解析为类型

注意:我已将“selenium-server-standalone-2.33.0.jar”添加到 Java 构建路径

4

3 回答 3

1

只需要一个导入语句来修复错误。导入以下内容,就是这样:

import org.openqa.selenium.WebDriver;
于 2013-07-02T12:02:37.920 回答
0

您需要正确安装此处提供的 android 服务器http://code.google.com/p/selenium/downloads/list

按照本教程http://code.google.com/p/selenium/wiki/AndroidDriver#Install_the_Android_SDK

关于如何安装 android web 驱动程序。

于 2013-07-02T09:53:41.180 回答
0

添加 - 导入 o​​rg.openqa.selenium.WebElement;

于 2016-05-04T14:19:40.943 回答