Selenium testing using Android Web Driver

Posted By : Dinesh Dhiman | 28-Apr-2015

Selenium testing using Android

We have to install first Android SDK
:-

 

  1. Download SDK form this link -- https://developer.android.com/sdk/index.html or go to the eclipse market install android development tool 

  2. Add api for creating AVD (Android Virtual Device)

  3. Create a AVD (emulator)

 

4. Start emulator

5. cd ~/android_sdk/tools/

6. ./android list targets

7.  ./emulator -avd android

8.  ~/android_sdk/platform-tools/adb devices

9. ./abd -s emulator-<id>  -e install -r  android-server.apk  (used for install android-server.apk in you emulaor for that first download apk file from net).

10 . ./adb -s  emulator-<id> shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity

11. ./adb -s  emulator-<id> shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity -e debug true

12 . ./adb -s emulator-<id> forward tcp:8080 tcp:8080

13. Open the web driver in emulator

14. Run your test testcase

 
 import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.android.AndroidDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class TestCase{
String url=”www.google.com ”;
WebDriver driver = new AndroidDriver();
@BeforeTest
	public void beforeTest() {
		 firefoxDriver.get(url);
	}
	@AfterTest
	public void afterTest() {
		firefoxDriver.close();
	}
@Test
  public void testGoogle(){
    WebElement element = driver.findElement(By.name("q"));
    element.sendKeys("selenium");
    element.submit();
  }
}

 

 

Thanks

Related Tags

About Author

Author Image
Dinesh Dhiman

Dinesh is good in java and grails with having extra knowledge in AngularJS , HTML ,SQL , Selenium

Request for Proposal

Name is required

Comment is required

Sending message..