Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
&引用;WebDriver无法解析为类型“0”;Android WebDriver java代码中出现错误_Java_Android_Eclipse_Selenium Webdriver_Adt - Fatal编程技术网

&引用;WebDriver无法解析为类型“0”;Android WebDriver java代码中出现错误

&引用;WebDriver无法解析为类型“0”;Android WebDriver java代码中出现错误,java,android,eclipse,selenium-webdriver,adt,Java,Android,Eclipse,Selenium Webdriver,Adt,我已经为使用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;

我已经为使用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();


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

您需要正确安装此处提供的android服务器

遵循本教程


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

只需一条导入语句即可修复错误。导入以下内容即可:

import org.openqa.selenium.WebDriver;

添加-导入org.openqa.selenium.WebElement

在链接中,你是否紧跟着代码后面的结构?它说你需要包括一些外部jarI,我已经添加了所需的外部jarI,谢谢权威人士的回答。但在安装上没有问题。我已经正确且成功地安装了“android-server-2.32.0.apk”。这是代码中的编译错误。嗨,我实际上是通过maven完成的。因此,我对解决方案不是很确定,但是您可以将selenium-java-2.33.0.jar文件添加到构建的路径中吗?我已经添加了selenium-java-2.33.0.jar。但不幸的是,没有人喜欢他。专家:非常感谢你的帮助和合作。我找到了解决办法。缺少一条导入语句:import org.openqa.selenium.WebDriver;