C# .NET - How to use selenium RC - Asked By abinav shankar on 03-Jan-12 05:05 AM

Hi

I want to implement test cases for web application and I am currently trying to use seleniumRc and i would like to get more details on how to implement the test cases using selenium Rc

Thanks

Jitendra Faye replied to abinav shankar on 03-Jan-12 05:09 AM
For that you have to configure this with c#,

First off, you need to get all these things (if you don’t have them):

  • http://release.seleniumhq.org/selenium-remote-control/1.0.1/selenium-remote-control-1.0.1-dist.zip
  • http://sourceforge.net/projects/nunit/files/NUnit%20Version%202/NUnit-2.5.2.9222.msi/download
  • http://www.mozilla.com/products/download.html?product=firefox-3.5.2&os=win&lang=en-US
  • http://release.openqa.org/selenium-ide/1.0.2/selenium-ide-1.0.2.xpi
  • http://www.java.com/en/download/index.jsp (You should already have this)



follow this link for more help-

http://thetestingblog.com/2009/09/10/selenium-rc-in-c-using-nunit-an-end-to-end-example/
Sri K replied to abinav shankar on 03-Jan-12 05:10 AM

If I remember correctly, "*chrome" is used to launch a special mode of Firefox (a mode in which your application has more privilegies -- with less security restrictions) ; so, the fact that it's Firefox that is launched, and not Google Chrome, is normal.

If you want to launch Google Chrome, you will have to use something else than "*chrome".


Using Selenium RC in interactive mode, with something like this :

$ java -jar selenium-server.jar -interactive 

and using the getNewBrowserSession command not correctly :

cmd=getNewBrowserSession 

I get the list of browsers is supports :

23:43:09.317 INFO - Got result: Failed to start new browser session: Browser not supported: (Did you forget to add a *?) Supported browsers include: *firefox *mock *firefoxproxy *pifirefox *chrome *iexploreproxy *iexplore *firefox3 *safariproxy *googlechrome *konqueror *firefox2 *safari *piiexplore *firefoxchrome *opera *iehta *custom on session null 

So, I'm guessing you should be able to launch Google Chrome using "*googlechrome" instead of "*chrome".


I'm not on Windows, so I can't try by myself... And I cannot find anything in the documentation to back me up... Still, with a bit of luck, this might help you...

Anyway, have fun !

http://www.peterkrantz.com/2005/selenium-for-aspnet/
As a sidenote : Google Chrome is not the one which invented the term "chrome", actually ; it means http://en.wikipedia.org/wiki/Chrome, like http://en.wikipedia.org/wiki/Chrome_Mozilla or http://en.wikipedia.org/wiki/User_interface_chrome

http://en.wikipedia.org/wiki/User_interface_chrome

Chintan Vaghela replied to abinav shankar on 03-Jan-12 05:44 AM

Here is how my code looks like:

A test method will look like somethink like this

    [TestMethod]
   
public void RegisterSpecialist(UserInfo usrInfo, CompanyInfo companyInfo)
   
{
       
var RegistrationPage = new PublicRegistrationPage(selenium)
             
.FillUserInfo(usrInfo)
             
.ContinueSecondStep();
       
RegistrationPage.FillCompanyInfo(companyInfo).ContinueLastStep();
       
RegistrationPage.FillSecurityInformation(usrInfo).ContinueFinishLastStep();
       
Assert.IsTrue(RegistrationPage.VerifySpecialistRegistrationMessagePayPal());
        selenium
.WaitForPageToLoad(Resources.GlobalResources.TimeOut);
        paypal
.LoginSandboxPage(usrInfo.sandboxaccount, usrInfo.sandboxpwd);
       
Assert.IsTrue(paypal.VerifyAmount(usrInfo));
        paypal
.SubmitPayment();
       
RegistrationPage.GetSpecialistInformation(usrInfo);
       
var bphome = new BPHomePage(selenium, string.Format(Resources.GlobalResources.LoginBPHomePage, usrInfo.AccountName, usrInfo.Password));
       
Assert.IsTrue(bphome.VerifyPageWasLoaded(usrInfo));
       
Assert.IsTrue(bphome.VerifySpecialistProfile());
        bphome
.Logout();
   
}

A page Object will be something like this

public class PublicRegistrationPage
{
   
public ISelenium selenium { get; set; }

   
#region Constructors
   
public PublicRegistrationPage(ISelenium sel)
   
{
        selenium
= sel;
        selenium
.Open(Resources.GlobalResources.PublicRegisterURL);
   
}
   
#endregion
   
#region Methods

   
public PublicRegistrationPage FillUserInfo(UserInfo usr)
   
{
        selenium
.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserFirstName", usr.FirstName);
        selenium
.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserLastName", usr.LastName);
        selenium
.Select("ctl00_cphComponent_ctlContent_wizRegister_ddlUserCountry", string.Format("label={0}",usr.Country ));
        selenium
.WaitForPageToLoad(Resources.GlobalResources.TimeOut);
        selenium
.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserEmail", usr.Email );
        selenium
.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserDirectTel", usr.DirectTel);
        selenium
.Type("ctl00_cphComponent_ctlContent_wizRegister_tUserMobile", usr.Mobile);
       
return this;
   
}
kalpana aparnathi replied to abinav shankar on 03-Jan-12 06:23 AM
hi

http://seleniumhq.org/docs/05_selenium_rc.html