Friday, December 11, 2009

Integrate Selenium server in Visual studio

It is very useful to run selenium in Visual Studio. All settings are on the picture below:



1) Open Visual Studio
2) On the Tools menu, choose External Tools.
3) In the External Tools dialog box, choose Add, and enter a name "Selenium Server" in the Title box.
4) In the Command box, enter the path to the Java Runtime. For example "C:\Program Files\Java\jre6\bin\java.exe"
5) In the Arguments box, enter arguments in the following format - "-jar selenium-server.jar".
6) In the Initial directory, enter "$(SolutionDir)\_tools\selenium"
7) Select Use output window and then choose OK.

Place selenium-server.jar file in $(SolutionDir)\_tools\selenium directory, commit it in SVN, so every developer will have the same version of Selenium as you.

Now server can be started/stopped through "Tools" menu.

11 comments:

Mik Kardash said...

Now I know whom to contact on the subject of Selenium employment on any project.

Yauheni Sivukha said...

Will glad to help! You know where to find me.

V said...

Hi,

I would like to know how to prepare MSBuild task which would automatically start the Selenium RC before executing the Selenium Tests.

Please help me to find the required .... XML, which would start selenium RC before executing the Selenium Tests.

Thanks,
Vijendra

V said...

Please let me know.

Veretax said...

This worked for me in VS 2005 after I changed the initial directory to $(ProjectDir)\_tools\selenium (Since I did not have a Solution file, just projects.

piyush said...

Please tell more clear about these two
1-In the Initial directory, enter "$(SolutionDir)\_tools\selenium"
2-Place selenium-server.jar file in $(SolutionDir)\_tools\selenium directory

V said...
This comment has been removed by the author.
V said...

Piyush,

In the Initial Directory put path of the directory where your java.exe file is present.

I will give yoy my configurations.

Open Visual Studio->Tools->External Tools-> Add

Title : Selenium RC

CommanD : C:\Program Files\Java\jre6\bin\java.exe

Arguments: -jar C:\Softwares\Selenium\selenium-remote-control-1.0.3\selenium-server-1.0.3\selenium-server.jar

Initial Directory : C:\Program Files\Java\jre6\bin\


Click OK

Yauheni Sivukha said...

Hi Vijendra,

Here is the script to start selenium from nant:
<target name="start.selenium.grid.rc">
<exec program="cmd" verbose="true" failonerror="false">

<arg value="/c" />
<arg value="java" />
<arg value="-classpath" />
<arg value="${rc.selenium.folder}\${selenium.server.file};${rc.selenium.folder}\${selenium.grid.rc.file}" />
<arg value="com.thoughtworks.selenium.grid.remotecontrol.SelfRegisteringRemoteControlLauncher" />
<arg value="-host" />
<arg value="${rc.host}" />
<arg value="-port" />
<arg value="${rc.port}" />
<arg value="-hubURL" />
<arg value="${rc.hubURL}" />
</exec>
</target>

I believe that MSBuild task will be very similar to it.

you can find more useful selenium tasks by link http://code.google.com/p/design-of-selenium-tests-for-asp-net/source/browse/trunk/_build/scripts/common.target

V said...

Thanks Yauheni i will look into the URL you have sent to me.

Anonymous said...

Thank you!
Works properly. Before I launched Selenium server using batch file. Now it is more easy. Hope to see more your blogs.