我已经为使用 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 构建路径