tags:

views:

385

answers:

1

Hi All,

I'm researching Selenium and have a seminar for my group... I meet many troubles with this I use C# language and write a demo SeleniumExample.dll Then i start selenium RC and NUnit and run it with nUnit to see the test report. I read testdata from xml.

Here's the SeleniumExample.dll: using System;

using System.Xml;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;

namespace SeleniumExample
{

   public class Success_Login
   {

      //User defined

       private string strURL = "http://newtours.demoaut.com/
mercurywelcome.php";
       private string[] strBrowser = new string[3] { "*iehta",
"*firefox", "*safari" };

       // System defined
       private ISelenium selenium;
               private StringBuilder verificationErrors ;

               [SetUp]
               public void SetupTest()
               {
                       selenium = new DefaultSelenium("localhost", 4444,
this.strBrowser[0], this.strURL);
                       selenium.Start();
                       verificationErrors = new StringBuilder();
               }

               [TearDown]
               public void TeardownTest()
               {
                       try
                       {
                               selenium.Stop();
                       }
                       catch (Exception)
                       {
                               // Ignore errors if unable to close the browser
                       }
                       Assert.AreEqual("", verificationErrors.ToString());
               }

               [Test]
       public void Success_LoginTest()
               {
           try
           {
               XmlDocument doc = new XmlDocument();
               XmlNode docNode;

               doc.Load("XMLFile1.xml");
               docNode = doc["TestCase"];

               foreach (XmlNode node in docNode)
               {
                   selenium.Open("/");
                   selenium.Type("userName",
node["username"].InnerText);
                   selenium.Type("password",
node["password"].InnerText);
                   selenium.Click("login");
                   selenium.WaitForPageToLoad("30000");
                   Assert.AreEqual("Find a Flight: Mercury Tours:",
selenium.GetTitle());
               }
           }
           catch (AssertionException e)
           {
               verificationErrors.Append(e.Message);
           }
               }
   }
}

Now I wan to have a demo that using Selenium Grid (SG) but i dont know how to do. I read document and understand the way SG works. I install SG and install Ant1.8. The tests will communicate with Selenium Hub. Actually, I just understand the theory i dont know how to make the tests communicate with Selenium Hub and how to make Selenium Hub control Selenium RC.

I am a new for Selenium. If anyone know this, please help me. I appreciate it so much.

THANKS, Hoang

+1  A: 

In reality there is no major difference between Selenium RC and Selenium Grid. The only difference is that with Grid you don't have to know where the RC nodes are but if you use Selenium RC you will have to.

string hubAddress = "machineNameWithSeleniumGridHub"

[SetUp]
public void SetupTest()
{
    selenium = new DefaultSelenium(hubAddress, 4444,this.strBrowser[0], this.strURL);
    selenium.Start();
    verificationErrors = new StringBuilder();
}

When your tests run they will speak to the hub which will then push the commands out to the first available RC. I have a Selenium Tutorial on my site. It uses C# and should get you going.

AutomatedTester
Thanks for helping me. I'm reading your site. Also I try to use selenium grid. I will let you know when i got the result...Once again, Thanks so much ^^