Following are the steps to setup environment : ANDROID TESTING using c#
1. Install SDK and install 4.0.3 Android API's.
2. Install AVD Manager and create AVD using 4.0.3 Android API'.
3. Start AVD by clicking on Start button and launch virtual device.
4. Open command prompt and browse the path of SDK directory under platform-tools folder to run the adb commands for example I had set the path D:\android-sdk-windows\platform-tools
5. Every device or emulator has a serial ID. Run this command to get the serial ID of the device or emulator you want to use and check whether to check the active state:
> adb devices
6. Download the Android server apk file 'android-server-2.0b3-patched2.apk' from http://code.google.com/p/selenium/downloads/list. To install the application do:
> adb -s emulator-5554 -e install -r D:\android-sdk-windows\platform-tools\android-server-2.0b3-patched2.apk
7. Start the Android WebDriver application through the UI of the device, click on WebDriver link button,
or by running this command:
> adb -s emulator-5554 shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity
and confirm Jetty Server started, if this confirmation fails on the emulator UI then run these commands,
> adb kill-server
> adb start-server
then re-start from step 3 again till then you would not get confirmation.
8. Now we need to setup the port forwarding in order to forward traffic from the host machine to the emulator. In a terminal type:
> adb forward tcp:8080 tcp:8080
9. Start Selenium Server on the machine :
> java -jar selenium-server-standalone-2.0b2.jar -proxyInjectionMode -trustAllSSLCertificates -log selenium.log
10. Now, execute the C# code for this built setup:
[TestClass]
public class AndroidApp
{
private IWebDriver WebDriver;
[TestInitialize]
public void TestInitializeAttribute()
{
try
{
WebDriver = new AndroidDriver();
WebDriver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30)); WebDriver.Manage().Cookies.DeleteAllCookies(); WebDriver.Navigate().GoToUrl("http://google.co.in");
} catch (Exception) { throw; } }
Now, you have done successfully and ready to start testing:)
Note: Always use the correct version of Android API with *.apk file.
This is really nice, helps a lot.
ReplyDeleteHey, Very Helpful Post :)
ReplyDeleteThanks for posting this artcile ..i believe it is the only one on the web which talk about android browser automation using C#..
ReplyDeleteI have one problem , which DLL or namespace AndroidDriver is referenced? I am getting (the type or namespace AndroidDriver couldn't be found)
what was the purpose of starting the selenium-server-standalone-2.0b2.jar i do not see anything on the code using the selenium server.
ReplyDeleteHi, thank you for the tutorial, but i have a problem with Jetty on Step 7, jetty connect on 5037 port but doesn't appears on emulator no matter how i try repeat from 3. step
ReplyDeleteawesome dude...kep going
ReplyDeleteHi,
ReplyDeleteCan you please let me know how to get these lines in using C#. I don't see the AndroidDriver in IWebDriver.
private IWebDriver WebDriver;
WebDriver = new AndroidDriver();
HI, this is the only post i found on C#, unfortunately i couldnt view images not sure wt the problem is, can some one mail me the images to kprasadbio@gmail.com please.
ReplyDeleteNice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
ReplyDeleteMobile App Development Company
Android app Development Company
ios app development Company
Mobile App Development Companies
Nice it seems to be good post... It will get readers engagement on the article since readers engagement plays an vital role in every blog.. i am expecting more updated posts from your hands.
ReplyDeleteMobile App Development Company
Mobile App Development Companies
ReplyDeleteThank you for your post. This is excellent information. It is amazing and wonderful to visit your blog.
ios app development course
iPhone training institute in bangalore