Thursday 12 January 2012

Writing test script android web applications in Android Emulator using CSharp with Visual Studio

1. Open visual Studio IDE
2. File>New>Project>C# Library Project
3. Go to Project Explorer
4. Click on Add Reference and browse for Android Webdriver Source files
5. Select all files net 35 or net 40 (i.e Depends on Target Framework) and add NUnit Framework.dll to this project
3. Copy the below script into your Visual studio Editor ( Using NUnit Frame work)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium.Android;
using OpenQA.Selenium;

namespace GoogleAndroidTest
{
        [TestFixture]
        public class AndroidTest
    {
            private IWebDriver driver;
            [SetUp]
            public void setupTest()
            {
                driver = new AndroidDriver("http://localhost:8080/wd/hub");
            }
           [Test]
            public void test()
            {
                driver.Navigate().GoToUrl("http://google.co.in");
                driver.FindElement(By.Name("q")).SendKeys("selenium");
            }
    }
  }


No comments:

Post a Comment