Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8227015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:58:33+00:00 2026-06-07T15:58:33+00:00

This seems simple, but for some reason I’ve not got it to work. I’m

  • 0

This seems simple, but for some reason I’ve not got it to work.

I’m using Selenium with Nunit.

I have one class called ‘Registration_Test’ in which I have a method named ‘completeRegistrationForm()’ which does as described.

I would like this method to be available for me to call in a number of different tests.

This is what I have in my second test.

Registration_Test reg = new Registration_Test();
reg.completeRegistrationForm();

This compiles happily but when I run it in Nunit I get the following:

SeleniumTests.Check_Links.Check_linksTest:
System.NullReferenceException : Object reference not set to an instance of an object.

and it indicates that reg.completeRegistrationForm(); line is the culprit.

Appreciate any help you can offer.

Here are my two tests:

Registration-test.cs

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

    [SetUp]
    public void SetupTest()
    {
        selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://custom-creative-404-dropbox:8080/");
        selenium.Start();
        verificationErrors = new StringBuilder();
    }

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

    [Test]
    public void Registration()
    {

        completeRegistrationForm();

        //back to home page.
        selenium.Click("link=Home");
        selenium.WaitForPageToLoad("30000");
    }


    public void completeRegistrationForm()
    {
        selenium.Open("/");
        selenium.Click("link=Register");
        selenium.WaitForPageToLoad("30000");

        string uniqueVal = selenium.GetEval("\"AutomatedTest\" + (new Date().getDate()) + (new Date().getTime())");
        //use moment instead.

        selenium.Type("id=RegistrationForm_TxtName", uniqueVal);

        selenium.Type("id=RegistrationForm_TxtUserName", uniqueVal + "@creative-404.com");
        selenium.Type("id=RegistrationForm_TxtPassword", uniqueVal);
        selenium.Type("id=RegistrationForm_TxtRePassword", uniqueVal);
        selenium.Click("id=RegistrationForm_Button1");
        selenium.WaitForPageToLoad("30000");

        for (int second = 0; ; second++)
        {
            if (second >= 60) Assert.Fail("timeout");
            try
            {
                if (selenium.IsTextPresent("Registration was successful!")) break;
            }
            catch (Exception)
            {
                Console.Write("Unable to find the Registration successful message. Something has gone wrong..");
            }
            Thread.Sleep(1000);
        }
    }

}
}

and Test-Links.cs (this test was made really just to test this out)

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

    [SetUp]
    public void SetupTest()
    {
        selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://custom-creative-404-dropbox:8080/");
        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 Check_linksTest()
    {
        Registration_Test reg = new Registration_Test();
        reg.completeRegistrationForm();

        selenium.Open("/home.aspx");
        selenium.Click("link=Home");
        selenium.WaitForPageToLoad("30000");
        selenium.Click("link=Gallery");
        selenium.WaitForPageToLoad("30000");
    }
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:58:34+00:00Added an answer on June 7, 2026 at 3:58 pm

    You can attach to the nUnit process to debug the failing line http://frater.wordpress.com/2010/05/04/debugging-nunit-tests-under-visual-studio-2010/.

    You can configure visual studio to break on exceptions in Debug>Exceptions. Next to “Common Language Runtime Exceptions” select “User-unhandled”.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like it should be really simple, but for some reason, I'm not
This seems like it should be fairly simple, but for some reason I can't
I am getting stuck on this problem. It seems simple but for some reason
This seems really simple, but for some reason Im stumped.. Im dynamically generating an
This seems like it should be quite simple, but for some reason I can't
This is probably something really simple but for some reason I just can't seem
This seems simple but I've exhausted my Google search patience. I have a RelativeLayout
This seems painfully simple, but I can't work out how to do it: I
I feel like this must be very simple, but for some reason I am
This should be a simple matter, but for some reason I can't grasp it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.