"WebDriver cannot be resolved to a type" error in Android WebDriver java code
10,282
Only one import statement is needed to fix the error. import the following and that's it:
import org.openqa.selenium.WebDriver;
Comments
-
Ripon Al Wasim almost 2 years
I have prepared the environment for test automation of Android Application using eclipse. I have followed the instruction from the below site:
https://code.google.com/p/selenium/wiki/AndroidDriver#Setup_the_Environment
I have copied the following code from the above website as below:
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(); } }
But error as "WebDriver cannot be resolved to a type" was found at the following line:
WebDriver driver = new AndroidDriver();
Note: I have added "selenium-server-standalone-2.33.0.jar" to Java Build Path
-
Ripon Al Wasim almost 11 yearsThanks pundit for your answer. But no problem in installation. I have installed "android-server-2.32.0.apk" properly and successfully. It's compile error in code.
-
pundit almost 11 yearsHi I have actually done it through maven. So not very sure of the solution but can you please add the selenium-java-2.33.0.jar file to the built path
-
Ripon Al Wasim almost 11 yearsI have added selenium-java-2.33.0.jar. But unfortunately no favour
-
Ripon Al Wasim almost 11 yearshi pundit: many thanks for your help and cooperation. I have got the solution. One import statement is missed: import org.openqa.selenium.WebDriver;