Selenium testing using Android Web Driver
Posted By : Dinesh Dhiman | 28-Apr-2015
We have to install first Android SDK :-
-
Download SDK form this link -- https://developer.android.com/sdk/index.html or go to the eclipse market install android development tool
-
Add api for creating AVD (Android Virtual Device)
-
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
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Dinesh Dhiman
Dinesh is good in java and grails with having extra knowledge in AngularJS , HTML ,SQL , Selenium