Search Here!

Friday, April 27, 2012

Selenium RC: Android Testing using C#

We can use Selenium RC for Android Testing in C# code, here below how to use this :)


 public static ISelenium GetSeleniumInstance()
        {
            return Thread.GetData(Thread.GetNamedDataSlot("SeleniumInstance")) as ISelenium;
        }


public static IWebDriver GetWebDriverInstance()
        {
            return Thread.GetData(Thread.GetNamedDataSlot("WebDriverInstance")) as IWebDriver;
        }       
-------------------------------
        IWebDriver _webDriver;
        protected IWebDriver WebDriver { get { return GetWebDriverInstance(); } }
        ISelenium _selenium;
        protected ISelenium Selenium { get { return GetSeleniumInstance(); } } 
------------------------------
const BrowserUrl = ConfigurationManager.AppSettings["browserUrl"]; // Defined in app. config


            _webDriver = new AndroidDriver();
            _webDriver.Navigate().GoToUrl(browserUrl);
            _selenium = new WebDriverBackedSelenium(_webDriver, BrowserUrl);
            _selenium.Start();
            Thread.SetData(Thread.GetNamedDataSlot("WebDriverInstance"), _webDriver);
            Thread.SetData(Thread.GetNamedDataSlot("SeleniumInstance"), _selenium);

Note: I am using all Dll's of version 2.6.0.0  

No comments:

Post a Comment