How to configure Selenium to work with Visual Studio .NET using C #?

I tried to use Google, but there are many different ways to work with Selenium. I use: - Windows 2003 Server - Visual Studio 2008 - Selenium IDE installed through Firefox - NUnit 2.5 is copied to C: \ - Selenium RC is copied to C: \

  • First I created a library project using C #.
  • And this is my class:
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;

namespace SeleniumTest
{
    [TestFixture]
    public class NewTest
    {
        private ISelenium selenium;
        private StringBuilder verificationErrors;

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

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

        [Test]
        public void TheNewTest ()
        {
            selenium.Open ("/google.com");
        }
    }
}
    
  • Next, add all the links from C: \ Selenium RC \ selenium-dotnet-client-driver-1.0.1
  • Compiled library project, succeeded. No mistakes.
  • Run NUnit.exe, now the errors are: (

SeleniumTest.NewTest.TheNewTest: Selenium.SeleniumException: XHR : URL = http://localhost:4444/google.comResponse_Code = 403 Error_Message = + +

+3
3

Forbidden, baseURL Selenium RC. http://www.google.com,

    [Test]
    public void TheNewTest()
    {
        selenium.Open( "/" );
    }

    [Test]
    public void TheNewTest()
    {
        selenium.Open( "http://www.google.com" );
    }
+2

ide # visual studio express. nUnit . .

#, nUnit selenium VSExpress

- Selenium Nunit #

0
  • .
  • , NuGet.
  • selenium install selenium selenium.
  • chrome, IEDriver, gecko, - .
  • .

    [TestClass]   //ReSharper    public class Test  {   [ ]   public void LoginTest()   {   //     }   }

0

Source: https://habr.com/ru/post/1756995/


All Articles