Problem Using Selenium Toolkit

Mar 26, 2010 at 4:36 PM

Hallo, 

i am trying to use the selenium toolkit but faced some problems. I try to run the example using configuration but the test fails and the message i get is System.NullReferenceException: Object reference not set to an instance of an object.

The test i run is very simple, it just opens the google home page.

Any help would be great!

Coordinator
Mar 26, 2010 at 6:39 PM

Can you post your test?  Also, please indicate which version of NUnit you are using and the browser and version your test is trying to launch.

My first impression is that you are missing the [WebTestFixture] and/or the [WebTest] method on the test fixture.

 

Mar 27, 2010 at 1:08 AM

First I wrote the test as it appears at the quick start guide but it could not be built.

using Selenium.Toolkit;
using Selenium;

namespace Example
{
    [WebTestFixture(BaseUrl="http://www.codeplex.com", Timeout=90000, Browser="*iexplore"]
    public class Simple
    {
          [WebTest]
          public void CanOpenHomePage()
          {
                 ISelenium selenium = Browser.Current;

                 selenium.Open("/");
          }
    }
}

Then i made some changes and the build succeeded but when i tried to load the project on nunit it could not find any test....

using SeleniumToolkit;
using Selenium;

namespace SimpleTest
{
    [WebFixture("*iexplore","http://www.codeplex.com")]
    public class SimpleTest
    {
        [WebTest]
        public void CanOpenHomePage()
        {
            ISelenium selenium = Browser.Current;
            selenium.Open("/");
        }
    }
}

I am using nunit 2.4.8 (I also tried on nunit 2.5.3 but it also didn't run) and the browser i try to load is Internet Explorer.

Below I will post a test i did and succeeded but without the use of the toolkit.

using NUnit.Framework;
using Selenium;

namespace SeleniumTests
{
    [TestFixture]
    public class DemoTest
    {
        private ISelenium selenium;
        private StringBuilder verificationErrors;

        [SetUp]
        public void SetupTest()
        {
            selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.codeplex.com/");
            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 TheDemoTest()
        {
            selenium.Open("/");
        }
    }
}

 

 

 

using NUnit.Framework;
using Selenium;
namespace SeleniumTests
{
    [TestFixture]
    public class DemoTest
    {
        private ISelenium selenium;
        private StringBuilder verificationErrors;
        [SetUp]
        public void SetupTest()
        {
            selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.codeplex.com/");
            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 TheDemoTest()
        {
            selenium.Open("/");
        }
    }
}

 

Mar 27, 2010 at 1:19 AM
tassos_k wrote:

the test fails and the message i get is System.NullReferenceException: Object reference not set to an instance of an object.

The test i run is very simple, it just opens the google home page.

 

Just another thing to mention about this message. When i got this message from nunit I used [TestFixture] & [Test] instead of [WebTestFixture] & [WebTest] just to make the test run. When I use [WebTestFixture] & [WebTest] the message i get from nunit is: "Not A Test Assembly. This assembly was not built with any known test framework."

Coordinator
Mar 27, 2010 at 5:46 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Mar 27, 2010 at 5:58 AM
Edited Mar 27, 2010 at 5:59 AM

Tassos_k,

Thanks for pointing out the issues with the Quick Start documentation.  It incorrectly stated the namespaces and referred to the original release which was compatible with NUnit 2.4.8.

I've been away from the project for a short while, your email motivated me.  Now all I need is some free time.  Please refer to the ticket http://seleniumtoolkit.codeplex.com/WorkItem/View.aspx?WorkItemId=10532 for updates