Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I have extracted the following code from selenium IDE.(c# remote control)

using System;

using System.Text;

using System.Text.RegularExpressions;

using System.Threading;

using NUnit.Framework;

using Selenium;

namespace SeleniumTests

{

[TestFixture]

public class MyFirstVCTest

{

    private ISelenium selenium;

    private StringBuilder verificationErrors;

    [Test]

    public void TheNewTest()

    {

        selenium.Open("/");

    } 

    [SetUp]

    public void SetupTest()

    {

        selenium = new DefaultSelenium("localhost", 4444, "*chrome","http://demo.volunteercampaigns.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 TheMyFirstVCTest()

    {

        selenium.Open("/?AspxAutoDetectCookieSupport=1");

        selenium.Click("link=Login");

        selenium.WaitForPageToLoad("30000");

        selenium.Type("id=ctl00_ContentPlaceHolder1_txtEmailAddress", "[email protected]");

        selenium.Type("id=ctl00_ContentPlaceHolder1_txtPassword", "orbs123");

        selenium.Click("id=ctl00_ContentPlaceHolder1_btnlogin");

        selenium.WaitForPageToLoad("30000");

        selenium.Click("id=ctl00_lblUserName");

        selenium.Click("id=ctl00_lnkSignOut");

        selenium.WaitForPageToLoad("30000");

    }

}

}

I created a webform and added a button there.

in the button click event, I wrote this code

SeleniumTests.MyFirstVCTest m = new SeleniumTests.MyFirstVCTest();

    m.SetupTest();

    m.TheMyFirstVCTest();

    m.TeardownTest();

I included all the .dll files. its running fine(no errors and warnings).

but after clicking the button I am getting the following error

No connection could be made because the target machine actively refused it 127.0.0.1:4444

What should I do??

Thanks in advance.

1 Answer

0 votes
by (62.9k points)

First, update your net service references used in your application.

If net service references aren't updated, then check all files and folder containing source code files in your web service project solution, rebuild it and then update web-references used in your project.

Else if it's operating fine then you would like to check your network services employed by your development server and windows firewall settings that are to check that your connection isn't min proxy mode.

In Windows 7 go to "Internet Options" within the "Connection" tab click on "LAN Settings" and uncheck everything.

I also encountered the same problem and I came to know that I was referencing the wrong folder having the same name but used in another solution.

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium certification online!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...