gpt4 book ai didi

java - Android WebDriver java 代码中的 "WebDriver cannot be resolved to a type"错误

转载 作者:行者123 更新时间:2023-11-30 11:31:02 25 4
gpt4 key购买 nike

我已经准备好使用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 cannot be resolved to a type

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

最佳答案

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

import org.openqa.selenium.WebDriver;

关于java - Android WebDriver java 代码中的 "WebDriver cannot be resolved to a type"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17422296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com