How to run AndroidDriver test with Junit?
I followed the instructions below:
http://code.google.com/p/selenium/wiki/AndroidDriver
And I was able to refine the following:
- Installed Android SDK
- Updated
- AVD image made and launched.
- Installed Eclipse and ADT plugin but haven't learned Eclipse yet. (I'm trying to compile things from the command line only.)
- Emulate Android emulator.
- Install WebDriver APK for emulation using adb -s -e install -r
- Configure port forwarding for the above
- Initial Webdriver is displayed on the emulator
- Loaded selenium-java-x.jar
- Downloaded junit-x.jar
- Defined classpath for compiling code
-
Compiled using javac, I don't know if this is correct:
javac -classpath c: _projects \ junit \ junit-4.10.jar; c: _projects \ selenium-java \ selenium-java-2.17.0.jar OneTest.java
Here's my test:
import junit.framework.TestCase;
import org.openqa.selenium.WebDriver; //VERY IMPORTANT. This line is not in the example on the Selenium AndroidDriver website.
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();
}
}
Now I am stuck with this section: http://code.google.com/p/selenium/wiki/AndroidDriver#Build_the_Android_Code
Where can I run these commands? For example $. / Go android_client etc. I think I just need to know how to compile correctly and how to redirect this test to the emulator. But I could be completely wrong.
My versions:
- Eclipse: 3.7.1
- Selenium Server: 2.17.0
- AndroidDriver: 2.16.0
- Android SDK Tools Revision 16
source to share
Remembering the steps you have taken so far and this excerpt:
Now I am stuck with this section: http://code.google.com/p/selenium/wiki/AndroidDriver#Build_the_Android_Code
Where can I run these commands? For example $. / Go android_client etc.
The section is for generating Andriod WebDriver code. I suggest that you do not run these commands as this section is not required to run the tests, which is your intent, compiled from the excerpt below:
I think I just need to know how to compile correctly and how to send this test to the emulator. But I could be completely wrong trace.
You have basically done all the basic work and at this point all you have to do is run the test file.
You may try:
There is some useful information about getting and running Eclipse here . Assuming you are running Eclipse (Junit is already connected to eclipse), you can right-click your test file in the Package Explorer window in Eclipse, then click Run As> Test to Remove.
Hope it helps.
source to share