Selenium RC in C# using NUnit: An End-to-End Example

Posted on September 10, 2009. Filed under: Tools,test automation | Tags: , , , , , , , |

This may come as a shock to many of you, but I’m kinda a dummy. (Collective gasps echoing through the Web.) I know! It’s hard to believe, but that’s why I’m such a great tester: I don’t take much for granted. I hate technology tutorials that kind of wing the details. The devil is in the details, YOU DUMMY! The common sense thing that you omitted might be the one thing that your reader is missing!

Because I love my readers and aspiring software testers, I’m going to give a dummy tutorial on how to get Selenium RC up and running for C#.NET users using NUnit. I’m going to cover every painful detail. I’m confident once you have this example running, you should be able to do a whole lot of things (assuming you have some basic coding skills).

First off, you need to get all these things (if you don’t have them):


Install instructions for the downloads:

Selenium RC
-No installation necessary. Just find a permanent location and unzip it there. I unzipped mine at C:\ just to make things simple

NUnit, Firefox, and Java
-Just run the respective installs with all defaults selected.

Selenium IDE
-To install, right click on the file and select “Open With…”
-Select Firefox in the programs list. If it’s not in the immediate menu, browse to it. (default location should be “C:\Program Files\Mozilla Firefox\firefox.exe
-When Firefox launches, click button in the dialog box that says “Install Now”.
-After the install of the plug-in, hit the “Restart Firefox” button when you see it.


Phase One: Record a Test using Selenium IDE

Okay, so, now that you have the tools, we’re going to record a simple test in Selenium IDE. Even though we want to eventually run the test in Selenium RC, Selenium IDE is a great tool for getting the basic test recorded since it’s all UI point and click.

  • Start up Firefox.
  • Click on the “Tools” menu and click on “Selenium IDE”
  • (Take your time to explore the Selenium IDE form)
  • Notice that it’s already recording.  The red circle button on the right side is pressed in:
  • Type “www.google.com” the main Firefox browser address bar and navigate to it.
  • In the search box, type in “thetestingblog.com” and hit the “I’m Feeling Lucky” button.
  • Notice in your Selenium IDE window that steps are being recorded.
  • With any luck, you hopefully landed on this blog’s home page.
  • Highlight the text “Daniel Brown” on the page, right click.  You should select the option that says “VerifyTextPresent Daniel Brown”.  See below:

Screenshot_VerifyTextPresent

  • Okay, we got our test recorded.  Now let’s run it to make sure it passes.
  • Unclick the red circle button to turn off recording.
  • Click on the green play triangle with the single bar to run the test

Screenshot_PassedIDETest

  • All green, it passed.  Good.
  • Now we want to convert this test to C#.
  • Select “Options ->Format -> C# – Selenium RC” from the Selenium IDE window.

Screenshot_ConvertToCSharp

  • Next select all the C# code and copy it.

Phase Two: Setup the C# Test Project

  • Open up Visual Studio
  • Select “File ->New ->Project”
  • In the New Project window under project types, select “Visual C# ->Windows”
  • Select the “Class Library” Template and name it something like “TestingBlogSeleniumRc” and click “Ok”.
  • It will create the project along with a file called “Class1.cs”.  Paste your SeleniumIDE test into that file.
  1. Rename “Class1.cs” to “FirstTest.cs”.
  2. In the code, change the namespace from “SeleniumTests” to “TestingBlogSeleniumRc”:
  3. Modify the class name from “Untitled” to “FirstTest”.  It’s good to change this so that if you add other tests, there won’t be any duplicated class names in the namespace (This has gotten me before, causing compile errors.).
  4. We also have to modify the Selenium instantiation to launch Internet Explorer.  Where it has “*chrome”, change it to “*iehta”.
  5. Where it has “http://change-this-to-the-site-you-are-testing/”, change it to “http://www.google.com”.

ModifySeleniumTestFile

  • Next we need to add all the references so this thing will run.
  • Go to the solution explorer, and right click on the “References” and select “Add Reference…”
  • Hit the “Browse” tab and navigate to where you unzipped your SeleniumRC files.  Look in the dotnet client driver folder.  Here’s the path to mine:

C:\selenium-remote-control-1.0.1\selenium-dotnet-client-driver-1.0.1\

  • Once you navigate to where the proper *.dlls are, select all of them and click “OK” to add them to the project.  (I know you can probably get away with adding less, but let’s keep it simple.)

Add References

  • Build the project to see if it works.  (Mine worked.  Hopefully yours did too.)

Phase Three: Running the Selenium RC test

  • In order to run the Selenium RC test, you first have to have the Selenium RC server running.  The Selenium RC server folder should be in the files you unzipped.  Normally, I have a batch file on my desktop created to run the Selenium Server, but for our purposes, we’ll just run this from the “Start -> Run” commandline, using this command:

java -jar C:\selenium-remote-control-1.0.1\selenium-server-1.0.1\selenium-server.jar

  • You should see some a dos window popup, and you will see something like the screenshot below.  DON”T CLOSE IT WHILE TESTING; IT NEEDS TO STAY RUNNING.  If you don’t have Java installed, this won’t work.  But most people should already have Java.

SeleniumServer

  • Next you need to launch the NUnit GUI to run the test from.  Since you installed NUnit, you should be able to navigate to it “Start -> All Programs -> NUnit 2.4.7 -> NUnit GUI (.NET 2.0)”
  • Once you open the NUnit runner, Click “File -> Open Project…” and navigate to the compiled dll from your test project.  For me, the path looks like this:

C:\Documents and Settings\dbrown1\My Documents\Visual Studio 2008\Projects\TestingBlogSeleniumRc\TestingBlogSeleniumRc\bin\Debug\TestingBlogSeleniumRc.dll

  • Once it loads, click on “Run” to start the test.

NUnit runner

If you got all green, congrats!  You just got your first passing Selenium RC test!  From here we can definitely get more complex. I’m sorry if I was too verbose, but I didn’t want to leave out any important details.  If you have any specific issues, please post a question; I’ll be happy to answer it.  Thanks for reading!

UPDATE  10/14/2009:

Thank you for your comment, Ron.  You pointed out something that I completely spaced on.  There’s one more step you need to complete before your test is ready.  You must get rid of the try-catch exception block.  As long as you have that block in your test, your test will never fail.  Nunit counts on an exception being thrown when an assert statement fails.  If that exception gets caught, then Nunit thinks that the test passed.  Why does Selenium IDE put that try-catch in when coverting the test to C#?  I have no idea.  I just know that it doesn’t need to be in there in our example.

BEFORE Try-Catch is removed:

18

AFTER Try-Catch is removed:

20

Just because I want to prove that it works, I will show you an example where I have two tests in the file.  One looks for the text “Jello Pudding”, and one looks for the text “Daniel Brown”.  Here’s code for the tests:

21

(Helpful Note to Nunit beginners: when Nunit runs, it executes the [SetUp]  method before each [Test] and [TearDown] method after each [Test] .)   After running the two tests, I have very contrasting results (as I figured I would).  The test that looks for “Daniel Brown” passed like a charm, but the test for “Jelly Pudding” failed:

23

The bar is solid red because one failure at any level of the tree is a failed test run.  THANKS RON!  Sorry to leave out something so important.

Another order of business is I didn’t mention in my article, as granular as it is, that you need Visual Studio!  THANKS DAWN!  I guess I just kind of assumed that you might have it if you are interested in running Selenium in C#.  Well, I hate to assume so if you don’t have Visual Studio, you can download a free copy of Visual C# 2008 Express Edition: http://www.microsoft.com/express/download/ I believe you can run this example using the express edition, but I haven’t tested it.  If you do test it, give me some feedback.  I’d like to hear how it works.  Also, instead of the Visual C# Express Edition, you may also be able to use the Microsoft Visual Web Developer, but again I haven’t tested it.  I don’t know for sure.

Make a Comment

Make a Comment: ( 72 so far )

blockquote and a tags work here.

72 Responses to “Selenium RC in C# using NUnit: An End-to-End Example”

RSS Feed for The Testing Blog Comments RSS Feed

Hi Daniel,
Thanks a lot for this post – finally someone who speaks “testing” language :)

Wow – super-comprehensive! I really appreciate the time you took to provide useful, detailed information.

I have tried ur instructions and got success at the end. Really its a fantastic article.

Really good article

This article is ‘THE BEST’. It has helped to learn basic Selenium RC.I have tried exact steps mentioned by u. However i m facing this problem.
IE window doesnt popup. I get an error message “Couldn’t open app window; is the pop-up blocker enabled?”.
I have disabled popup blocker but still I get this message.
I tried Firefox also. Firefox window opens but the link “http://www.google.com” doesn’t open and the operation is timed out.
Do i need to write selenium.WaitForPageToLoad();. If yes, where do i write?

Hi Schweta-

1- Is the Selenium server running?
2- Have you tried using the *iehta browser?
3- Have you tried “proxy injection mode”?

Please feel free to email me directly dcannan at gmail dot com if you have further trouble, and let’s see if we can work through it.

Seems like troubleshooting may be another good follow-up post, guys!

One other note … I have had a problem where the Selenium server never starts *completely*, because it is blocked by some antivirus program or something similar.

Make sure your command window with the Server in it gets all the way to the last line shown, that starts with “Started org.mortbay.jetty….”

This is a great article! I considered writing almost exactly the same kind of article a while ago, and have not gotten around to it, but you have covered everything I can think of!

When can we expect a follow-up, with some more advanced techniques of using Selenium RC in a C# script? Data-driving, perhaps?

(Actually, I’d be willing to collaborate, if you are interested)

[...] Selenium RC in C# using NUnit: An End-to-End Example « The Testing Blog thetestingblog.com/2009/09/10/selenium-rc-in-c-using-nunit-an-end-to-end-example – view page – cached Posted on September 10, 2009. Filed under: Tools, test automation | Tags: .NET testing, C#, NUnit, Selenium, Selenium IDE, Selenium RC, UI Testing, Web testing | — From the page [...]

I followed this closely and had success…as far as it goes. But what about conducting my first FAILed test? I changed the text to be found to something NOT on the page and repeated the process. The IDE failed the test, but the newly pasted C# still passed in NUNIT.

Ron, tell me if the solution listed above doesn’t fix your problem (Under Updated: 10/14/2009). Like I said above, Nunit depends on an exception being thrown on the assert to fail the test. We need to make sure those errors (failed assertions) aren’t getting caught or swallow or bubbled up somewhere else.

[Follow-up to my post of a few minutes ago] Page timeouts show up as errors in NUNIT, whereas a failled assertion to verifying text does not – the test passes.

That certainly does the trick – thank you.

Hi Daniel,
Thanks for such a great information. Selenium works fone with Visual C# express edition. Many thanks.

Social comments and analytics for this post…

This post was mentioned on Twitter by dckismet: @marisaseal Selenium example is a great post! Thanks for sharing! http://bit.ly/4MYp9...

Damn good article. Your work will be really appreciated. I know it might be really painful while writing this article in upcoming days we can also contribute to this article. Mail me about discussion thread on Selenium with C#, I would like to join u guys.

its quite good.but while running test suite in Nunit GUI.i have got an error “couldn’t open app window.is it pop-up bloker enabled?”.i disable popup blocker also in Internet Tools option.still im getting the error.help me,

If you have installed any Tool bar such as Google toolbar / Yahoo toolbar enable pop-up there also.

Just refer below URL for more details
http://jira.openqa.org/browse/SRC-733

Hi Friends,

I have added code for Data driven test using Excel file. Please follow the below link for more information.

http://seleniumcsharp.blogspot.com/

Hi the link is not available.. could you please send me the example. tomas_gotes@hotmail.com

Hi Thejesh,
I have to parametrize selenium script. I was checking for the link that you have provided, but blog is not present may be deleted.

Please help me by providing the code to parametrize the script.

Regards
Katrina

Hi Thejesh,
I need help on parametrize selenium scripts. I am not able to access your link.
It would of great help if you could send me the information on my email Id?

Hi,
I’m researching about Data Driven in Selenium. I found this forum but I cannot connect to http://seleniumcsharp.blogspot.com/ .Please help me
Thanks for your co-operation

Hi Daniel,
I stumbled upon your blog and it is as if I found a pot of gold at the end of the rainbow! I’m new to the testing world as I just got hired a month ago as a software test analyst @ Nexus On-Demand, Malaysia.

Your article is fantastic but I have one small problem. When I try to run phase three of the article that is to get my Selenium server running, my command box won’t appear at all(it did but only for a few millisecond!)

Is there anything I should turn off or on prior to this step? Please guide me through this.

Thanks,
Angie

Sure thing, Angela. Let me see if I can help you. Instead of launching the Selenium Server the way I told you, do it like this:

Click -> Start -> Run and type in “cmd”. Then click “ok”.
(This will launch a command window)
In the command window type in the command I gave you and press enter:

“java -jar C:\selenium-remote-control-1.0.1\selenium-server-1.0.1\selenium-server.jar”

I suspect it will fail because
1) your path is wrong (i.e. the command I gave you is not looking in the right location for the Selenium Server)
2)Java is not installed
3)Or Java is installed but not in the system path.

Try that and tell me what happens.

Hi Daniel,

I tried doing what you told but I get an error saying “Unable to access jarfile and the second error is that it “Unrecognized option:- Could not create the Java virtual machine”

1.My selenium server is installed in C:\
2.I’ve already installed java earlier
3.How do you know if Java is in the system path?

-Newbie-

Thanks for the posting i want some other futures regarding the selenium Rc and Selenium Grid can u explain it .How to generate the Text document for testing the web application .Whether it generates or we manually generate it

This is a very nice article.Well Described.
Can we test the cookie values present on a web page using this Selenium??
if we can please let me know.

Thanks in advance,
Pavan Kumar.

You may want to take a look at the Selenium Toolkit for .NET http://seleniumtoolkit.codeplex.com.

It provides a NUnit addin that takes care of the selenium-server.jar as well as externalizing the settings to simple configuration files.

Hi Bryan – thanks for the suggestion. I recently started using Sauce-RC, and it’s dead easy to install and configure as well.

Marisa

I’ve started to investigate SauceRC as well and the example online via the Qtime video uses python and it seems intuitive, but what if I’m using C#? I must be missing something obvious, but I can’t figure out how to use this tool for a C# test script with SauceRC. Any help would be much appreciated.

Hey Daniel,
I know this is irrelevant to your post here but I was wondering if you know any blog/forum/solution/answers to handle operations within pop windows using selenium.

My problem is this: the website that I’m currently testing has crazy amounts of pop ups. I cant seem to make selenium work within the pop up window e.g: clicking a link in the pop up window.

It would be great if you know any post or blogs or even have the solution for this matter.

Thanks for your help!

Angela

Hi Angela,

Do you have means of identifying the popup windows? If so, you could use SelectWindow – per the documentation, the method “Selects a popup window; once a popup window has been selected, all commands go to that window.”

Marisa

Hey Marisa,

Yeap,indeed I do. I tried using windowID but my Id keeps on changing so I’ve resorted to using title. It works perfectly fine but it’s just that the clicking of links wont work in the pop-up window.

Initially I even had problems with identifying the pop up. But now that I’ve got Selenium to recognize the pop up and close it, I still can’t make the operation within the pop up work. I’ve tried selectWindow, windowFocus etc but still no success.

Any advise?

Angela

Greeting,

Works like a charm! Outstanding post on integration these technologies into a test framework.

As an FYI I needed a reporting tool for the test results that worked well with NUnit. I found a tool called Nunit2Report http://nunit2report.sourceforge.net/.

However to get this to work I had to install and run NAnt.

The NAnt Intro here got me through the process with the least amount of pain. http://www.4guysfromrolla.com/articles/120104-1.aspx

Hi Daniel, great stuff. I am trying to run the selenium-server.jar for python scripts, but when I get to the equivalent command

java -jar C:\selenium-remote-control-1.0.1\selenium-server-1.0.1\selenium-server.jar

(In my case it looks like this:
java -jar selenium-server.jar -log kevlog -multiwindow -htmlSuite “*firefox C:\Programme\Mozilla Firefox\firefox.exe” “http://test2.www.haufe.haufe-ep.de/” “D:\Selinium_DEZ\Test_Suite16_dez_a” “D:\results.html” )

I get the dos window but the proxy won’t allow connection to org.mortbay.jetty.server

The error message looks like this:

“DEBUG [13] org.mortbay.http.HttpServer – Try HttpContext[/,/],0
11:22:29.734 DEBUG [13] org.mortbay.http.HttpContext – Handler org.openqa.selenium.server.ProxyHandler in HttpContext[/,/]
11:22:29.734 DEBUG [13] org.mortbay.http.HttpContext – Handled by org.openqa.selenium.server.ProxyHandler in HttpContext[/,/]
11:22:29.734 DEBUG [13] org.mortbay.http.HttpConnection – RESPONSE:
HTTP/1.1 403 Forbidden+for+Proxy ”

Any other nice verbose testers out there know how to fix this?

I tried putting http://www.mortbay.org in my no proxy for list in the Firefox settings, no joy.

Kevin,

I would try using SauceRC like my colleague Marisa. It simplifies all that. Basically you install it, and it starts a Selenium server for you. It puts an icon in your tray that you can left click on to “Configure …” In the config file, it has all the parameters laid out for you to comment/uncomment.

http://saucelabs.com/products/sauce-rc

Um, I think we had better drop the dummy thing Daniel :-) If there are any of those agile developers out there reading this, they will be rolling about laughing.

Using the Sauce RC worked fine, it ran the selenium-server for me and guess what….it crashes in exactly the same way as when I run it from a bat file using the command given above :-)

Here is the Sauce Log….
[Selenium RC] 2009-12-23 11:51:10.633 DEBUG – Try HttpContext[/,/],0
[Selenium RC] 2009-12-23 11:51:10.633 DEBUG – Handler org.openqa.selenium.server.ProxyHandler in HttpContext[/,/]
[Selenium RC] 2009-12-23 11:51:10.633 DEBUG – Handled by org.openqa.selenium.server.ProxyHandler in HttpContext[/,/]
[Selenium RC] 2009-12-23 11:51:10.633 DEBUG – RESPONSE:
[Selenium RC] 2009-12-23 HTTP/1.1 403 Forbidden+for+Proxy
[Selenium RC] 2009-12-23 Date: Wed, 23 Dec 2009 10:51:10 GMT
[Selenium RC] 2009-12-23 Server: Jetty/5.1.x (Windows XP/5.1 x86 java/1.6.0_12
[Selenium RC] 2009-12-23 Content-Type: text/html
[Selenium RC] 2009-12-23 Content-Length: 1244
[Selenium RC] 2009-12-23

Now I blame those pesky Open Source developers who misdesigned their tool to depend on the connection to jetty….

Have posted a question in the google support group here…

http://groups.google.com/group/selenium-users/browse_frm/thread/69a3114c3095f228#

Hi i am naveen i want to know
i am using selenium RC and selenium IDE.I want to know how to use selenium GRID can u help me.And the another think is What is the Report generated by an Nunit after succesful completion of the Run.Whether it can generate a similar thing like QTP or some other format.If we want to get the similar thing like Report of QTP what to do .

Reply me as early as possible

Thanking you

Naveen

Naveen,

I don’t really have much experience with Selenium GRID (yet) so I would be a poor help at this time. However, once I master it out, I might write a blog entry on it (no promises).

If you want a slick report to go with your Selenium tests, I might recommend Molybdenum.
https://addons.mozilla.org/en-US/firefox/addon/4149
It’s a Play Capture tool that’s very similar to Selenium IDE; it’s a FireFox plugin too. It has a very nice report that’s written out. You can convert your Selenium tests over to its syntax using its conversion tool. Plus, you can launch the tests from the command line. Hmm, maybe I’ll write a blog entry on it.

Daniel

Its a great help for a novice.
Thank You. :)

It would be nice to add a section on how to do all of this without NUNIT just with C# and Visual Studio. Selenium guide says “create a simple Main() executable project”. Well I guess it ain’t so simple as I am struggling with this for 3 days now without any luck. First of all in Visual Studio 2010 trying to create references work, but “using Selenium;” underlines Selenium with red line. I am really confused why. This is really upsetting when people (Selenium document creators) spend so much time on what seems like a good documentation, but omit very details that cause days of struggling.

Hi James–

I hear your frustration. Maybe I can help? I just downloaded the VS C# Express 2010 and walked through adding the reference and the using statement. I’d like to compare notes and see what’s going awry for you.

I know that these guys put effort toward covering details in this post, but it’s possible that some more details would help others like you. Let’s figure out which details were missed and then ask them to add it to the page.

-Dawn

Hello Dawn,

Thank you very much for responding to my post! I have described the steps performed below. It appears like a simple problem, but the devil is always in the details. :)

I am using Visual Studio 2010 Professional Beta 2. I am not sure if it is different in the Express version. Have you been able to successfully set the entry point up in VS 2010 C#?

Thank you,

James

James, I just created a Selenium test console app using VS 2008. Got it working no problem. Surely it’s not that 2010 is incompatible or something. That would be uber gay.

I’ll tell you what I’m going to do. Since I have an MSDN subscription, I’m going to get VS 2010, and I’m going to try it. I’m going to use: “Visual Studio 2010 Professional Beta 2″. That good? Or should I use a different version of VS 2010?

Visual Studio 2010 Professional Beta 2 is the version I have. I am not sure if there is a major difference with 2008 or express editions. Can you confirm that the steps outlined below are correct and it should work? Or am I missing something?

Thanks a lot!!

James, I read through your steps. Please condescend me for a second. Being the ignorant tester I am, let’s simplify things. Instead of adding two separate projects under the solution:
1)Just create the solution as a console app (with one project and one program file)
2)Add the Selenium references under the console app project.
3)Add the “Using Selenium;” in the “Program.cs” file.
4)Throw the Selenium code into the Main() and see if you can get it to work like that. I would just get rid of the separate methods (i.e. the Setup(), Test(), and TearDown()). Just put the content of those methods in the main. Put the ISelenium object in the main() too. Simplify. Maybe it will work?

Just out of curiosity, did you add the Selenium references to both projects? That could potentially cause a problem if you don’t have them in both. Maybe.

Hello Daniel,

I did as you outlined. Just one single Solution and Project. Added Selenium references to DLL files.
When adding
using Selenium;
to the code I am getting red underline, and the error below:

Error 13 The type or namespace name ‘Selenium’ could not be found (are you missing a using directive or an assembly reference?)

Then doing Rebuild on the entire project and still getting that error.

This is really odd, but is is precisely the issue I am trying to resolve.

With 2 projects I did add references to Selenium DLL’s to both.

using Selenium; gets red underline specifically in the Program.cs (Console Application)

If adding as a “Class Library” it does not get underlined, but then I don’t have an entry point.

Thank you!

James

James, did you ever get that problem fixed? I’ve been on vacation so I haven’t been real diligent in answering posts. I think I’m going to post a blog entry on creating a Selenium Test that’s runs as an executable via command line. I might need to download VS 2010 (still on VS 2008) just to see what the deal is. Sorry you’re having so much trouble.

Thanks so much for reading my post!

I still have not been able to figure out what the problem is. I am using Visual Studio 2008 Professional Beta 2 (not express).

1. I created “SeleniumProject” the way it is described on Selenium site:
http://seleniumhq.org/docs/appendix_installing_dotnet_driver_client.html

2. Then I right clicked on the Solution and added “Console Application” and called project “Main”. This is where I planned the start my Selenium program entry point: Program.cs.

3. Then I added references to Selenium libraries the same way as I did in step 1. Also, I added a reference to SeleniumProject.

4. In my Program.cs I added:
using Selenium;

and the word Selenium has a red underline.
Tried to “Rebuild Solution”, but still getting error: “The type or namespace name ‘Selenium’ could not be found (are you missing a using directive or an assembly reference?)

And this is what’s confusing. If all references are added correctly why would Visual Studio not recognize that. I think I may be missing a step, though it is not immediately obvious. I also doubt that this is a bug in VS 2010 beta. The problem seems to be very simple, but it’s been a week and still I cannot figure out how to create a simple entry point for Selenium program because of the issue described above.

If you happen to be able to create an entry point post for VS 2010 I would really appreciate it and be very thankful!

Thank you again for responding!

James

Sorry, I meant to say “I am using Visual Studio 2010 Professional Beta 2″ and not “Visual Studio 2008″

James, I tried to email you, but I haven’t gotten a response. Did you see my latest post: Selenium RC As a Console App. It’s a full example (URL below). Look at that. See if that helps. If not, let’s talk, man. I feel like the problem is something simple if we can just identify it.

http://thetestingblog.com/2010/02/02/selenium-rc-in-console-app/

Hello Daniel,

Thank you for your help and effort.
This is a very detailed state of the art blog entry!

I still have the same problem. But I think I may be a bit closer to understanding the problem. Suddenly, after opening Core DLL in the Object browser I started getting the following warning below in regards to ALL ThoughtWorks.Selenium DLL’s:

Warning 2 The referenced assembly “ThoughtWorks.Selenium.Core” could not be resolved because it has a dependency on “System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” which is not in the currently targeted framework “.NETFramework,Version=v4.0,Profile=Client”. SeleniumProject

I suspect this has something to do with .NET 4.0

In the end this whole thing could be an undiscovered bug within VS 2010 Beta2.

I will try to update .NET 4 (which I have installed with VS 2010) and if this does not help. I will uninstall VS2010 Beta2 and install VS2008 express.

Thank you Daniel, you are the best!!

James

Hi Danial,
Awesome blog, the steps which you describes are complete and not assuming (Complete Tester Language..:)), Well i tried to work with Selenium with Perl, haven’t tried yet selenium with C#, but after reading steps i know that i can able to do it…:)

Thanks again for your effort and time spent.

Dev..

Hello Daniel,

Excellent… it worked with Microsoft Visual C# 2008 Express Edition on Firefox….

Can we add our own code to validate certain scenarios which occur inside the web application??

Also I have another question is it possible to include existing methods to parameterize the scripts like providing the inputs through .xls file or some other data sheets instead of hard coding the values?? does NUnit supports this??

Really this is the best and wonder full article
reading this only i started running selenium RC
in C Sharp…… thank you very much…….
But i have some queries can i ask you….

Yeah….

Thanks for taking the time to put all the details in.

How can i execute directly from c# console
without creating class library.
(Not using Nunit )

Ivreddy,

Check out my article on creating a console app (no NUNIT needed):
http://thetestingblog.com/2010/02/02/selenium-rc-in-console-app/

Let me know if you were looking for something else.

Great article !! thanks a lot

Hi Daniel,

Nice post…I am into a image website testing and working on creating Selenium-C# scripts. I would like to have a proper framework and reporting structure. Can you throw some light on designing Framework and Result reporting structure? I may sound mean here but I really like the way you have explained the basic end-to-end example…Thanks again buddy! :)

how to handle the exceptions for popups during
data driven testing and is there a recovery
Scenario in selenium as it is available in QTP

To solve the problem of .NET 4 and the dll reference failure:
In Solution Explorer right-click on your project name and select Properties. From the Target Framawork box’s dropdown list, select .NET Framework 4.
You’ll get a “Target Framework Change” warning. If you don’t want to take the risk, copy your project to a new one and try again with confidence. I’ve changed the target framework several times without any problems.

Hello and thanks for this excellent post.
I just saw the among the comment here a question about error by using selenium in Visual Studio 2010. I’m having the same problem by Visual Studio 2010 Express.
It seems to be a problem with the selenium dll, which isn’t recognized (- even after adding the appropriate references, the “using Selenium” still have a red underline) – maybe becuse of using the .net framework 4.0?
I wonder if you’ve heard about any solutions to this problem?

awesome post…thankx a ton for this daniel well but how to parameterize the selenium tests….plz reply…m stuck on that…

Ravi, when you say “parameterize”, what do you mean? What are you trying to do? Do you want to run the same test many times, filling in the values from say a spreadsheet or a database? Describe what you’re trying to accomplish, and I’ll help. ;)

hey is it necessary to [Test],[setup] before every method

Those Headers [Test], [SetUp], [TearDown], etc. are simply directives for NUnit. They are necessary if you use NUnit to run your tests. If you are not using NUnit, but instead running the tests as a Console App, then they don’t matter.

The way NUnit works is that it calls that [SetUp] method before every [Test], then it calls the [TearDown] method. In each test class, you should only have one [SetUp] and one [TearDown]. But you can have multiple [Test] methods. Does that make sense?

Excellent post! Just what I needed, thank you :)


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...