tags:

views:

70

answers:

1

Hi everyone,

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

  1. First I created a Library Project using C#.
  2. And this 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" );
        }
    }
}
    
  1. Next add all references from the C:\Selenium RC\selenium-dotnet-client-driver-1.0.1
  2. Compiled the Library Project, succeeded. No errors.
  3. Run NUnit.exe, now errors :(

SeleniumTest.NewTest.TheNewTest: Selenium.SeleniumException : XHR ERROR: URL = http://localhost:4444/google.com Response_Code = 403 Error_Message = Forbidden+for+Proxy

+1  A: 

You are getting the Forbidden error because you are setting the baseURL to that of Selenium RC. You need to set it to http://www.google.com and then in your test would look like

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

or you need to change your test to

    [Test]
    public void TheNewTest()
    {
        selenium.Open( "http://www.google.com" );
    }
AutomatedTester
Hi there,I got new errors after change it to<pre> [Test] public void TheNewTest() { selenium.Open( "http://www.google.com" ); }</pre>SeleniumTest.NewTest.TheNewTest:Selenium.SeleniumException : ERROR: Command execution failure. Please search the forum at http://clearspace.openqa.org for error details from the log window. The error message is: Access is denied.
Chan
set the baseURL to http://www.google.com and then open("/");
AutomatedTester
I tried many different ways. Even I created a Console Application instead of Class Library to test it. But it seemed freezing instead of running http://google.com. The Selenium Remote Control v.2 appeared. And this is the link opened with Firefox : http://localhost:4444/selenium-server/core/Blank.html?start=trueCan you tell me where did I miss?ThanksThis is the blog:
Chan