views:

252

answers:

1

Hi, I need a help.........

I can launch some remote control by using: ant launch-remote-control

but I dont know how my script connect to hub? I set up ant, selenium-grid on the same computer. I have an grid.dll which is written by C# and run through NUnit. The test data is read from xml file (ValidData.xml) The example code is below :

using System.Collections.Generic; using System.Linq; using System.Text; using System; using System.Xml; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using Selenium;

namespace Grid { public class Class1 { //User defined

    private string strURL = "http://gmail.com/";
    private string[] strBrowser = new string[3] { "*iehta", "*firefox", "*safari" };
   string hubAddress = "192.168.20.131"; // IP of my computer

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

    [SetUp]
    public void SetupTest()
    {

        selenium = new DefaultSelenium(hubAddress, 4444, this.strBrowser[1], this.strURL);// do i need to identify browser when I defined it when launching a remote control
        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());
    }

    private string[] name;

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

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

            foreach (XmlNode node in docNode)
            {
                selenium.Open("/");
                selenium.WaitForPageToLoad("50000");
                selenium.Type("Email", node["username"].InnerText);
                selenium.Type("Passwd", node["password"].InnerText);
                selenium.Click("signIn");
                selenium.WaitForPageToLoad("100000");
                name = (selenium.GetText("//div[@id='guser']/nobr/b").Split('@'));

                try
                {
                    Assert.AreEqual(node["username"].InnerText, name[0]);
                    Assert.AreEqual("Sign out", selenium.GetText(":r6"));
                }
                catch (AssertionException e)
                {
                    verificationErrors.Append(e.Message);
                }

                selenium.Click(":r6");
            }
        }
        catch (AssertionException e)
        {
            verificationErrors.Append(e.Message);
        }
    }
}    

}

Step I run this script: 1.I build that script into DLL 2.I start hub by using command "ant lauch-hub" 3.I start 2 remote controls by using command : ant -Dport=5566 -Denvironment="*chrome" launch-remote-control ant -Dport=5577 -Denvironment="*iexplore" launch-remote-control 4.Then I open Nunit and load DLL (code above) and run 5.The NUNit doesnot respond anything.

I think there are some missing things but I dont know. How can the test script (DLL) know which is sequence of remote control is selected to run the test????

Please help me!! Thank you so much

Yui.

A: 

I do not see [TestFixture] attribute for Class1. May be that is the problem?

I described procedure of executing tests on selenium grid here: http://slmoloch.blogspot.com/2009/12/design-of-selenium-tests-for-aspnet_19.html. and you can download sources of tests here: http://code.google.com/p/design-of-selenium-tests-for-asp-net/

Yauheni Sivukha