JavaScud | Forum | JIRA | Blog |
  Dashboard > Selenium 中文 > ... > Selenium chinese translation road map > Selenium Remote Control - .NET
  Selenium 中文 Log In View a printable version of the current page.  
  Selenium Remote Control - .NET
Added by Tin Steeler, last edited by Tin Steeler on Nov 16, 2006  (view change)
Labels: 
(None)

Selenium Remote Control: Using the .NET Client Driver

NDoc reference is available

First, make sure you've already started the Selenium Server separately in another process. The Selenium Server should remain up and running throughout this process; you shouldn't need to start/stop it each time you use the Client Driver. (Though, of course, if you need to start and stop the server, you certainly can, just by automatically starting it from the command line.)

Right now the .NET Client Driver works with Microsoft.NET; we haven't really tried it with the Mono Project, though we'd be curious to hear from you if you can get it to work, or to change a few things if you can't get it to work.

To use the .NET Client Driver in Visual Studio, just add the ThoughtWorks.Selenium.Core.dll assembly as a reference to your VS project, and create a new DefaultSelenium object. You'll need to give it the hostname and port of the Selenium Server, the browser string to use with "getNewBrowserSession", and the base URL at which we'll start testing. When you're ready to begin, run the .start() method on your DefaultSelenium object; when it's time to close the browser, use the .stop() method.

The DefaultSelenium object is full of handy methods that handle your Selenium Commands. If one of them has an error (or if an "assert" command fails) the method will throw an exception with a handy error message, which you can wrap up in a try/catch block if you like.

You can use the .NET Client Driver together with any .NET testing framework like NUnit or the Visual Studio 2005 Team System, or it can be used without any testing framework at all; you can use the .NET Client Driver with any program whatsoever to automate tasks in your browser.

Examples: GoogleTest.cs, SeleniumIntegrationTest.cs.

VB Example
VB Example:

    Imports Selenium

    Module Module1

        Sub Main()
            Dim sel As DefaultSelenium = New DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com")
            sel.Start()
            sel.Open("http://www.google.com/webhp")
            sel.Type("q", "hello world")
            sel.Click("btnG")
            sel.Stop()


        End Sub

    End Module
Site running on a free Atlassian Confluence Open Source Project License granted to WebWork China. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.3 Build:#808 May 29, 2007) - Bug/feature request - Contact Administrators