Tuesday, November 16, 2010

How to setup Selenium Grid on Cloud MAC Server.

Here are the steps

1. Install VMWare Fusion on MAC server.
2. Load various OS/Browser VM's onto MAC SERVER
3. Create scripts to start and stop VM's from OS/X
4. Install Selenium Grid on MAC server
5. Create scripts to start and stop GRID.
6. Setup Selenium RC's on VM's and include RC's in the startup and run RC's on background.
7. Commands to Stop/Start GRID and VM's

Step1:

Download VMWare fusion from http://www.vmware.com/products/fusion/


Step2:

Create various OS/Browser VM's and Zip it and transfer onto MAC server

You can skip this step if MAC sever is located in your premises. You can transfer VM file using external hard driver or USB drive

For zipping use below command
gzip filename

A compressed file with extension .gz will be created.

To transfer the file to the MAC server use below command

navigate to the directory where file is located. Then enter below command

sftp macServerusername@macServerIP

it ask for password, enter the password, then “sftp<” promt will display.

Then enter below command

put filename

once transfer is completed, unzip the file. Use below command
gunzip filename


Step3: Create scripts to start and stop VM's from OS/X

Create a shell script  to start all VM's .

#!/bin/sh
cd /
cd Library/Application\ Support/VMware\ Fusion/

./vmrun -T ws start "/Users/test/ Vista IE7.vmwarevm"
./vmrun -T ws start "/Users/test/ Vista IE8-FF36.vmwarevm"
./vmrun -T ws start "/Users/test/ XP IE6.vmwarevm"
./vmrun -T ws start "/Users/test/ XP IE7.vmwarevm"
./vmrun -T ws start "/Users/test/ XP IE8-FF36.vmwarevm"


Create a shell script  to stop all VM's .

#!/bin/sh
cd /
cd Library/Application\ Support/VMware\ Fusion/

./vmrun -T ws stop "/Users/test/ Vista IE7.vmwarevm"
./vmrun -T ws stop "/Users/test/ Vista IE8-FF36.vmwarevm"
./vmrun -T ws stop "/Users/test/ XP IE6.vmwarevm"
./vmrun -T ws stop "/Users/test/ XP IE7.vmwarevm"
./vmrun -T ws stop "/Users/test/ XP IE8-FF36.vmwarevm"


Step 4: Install Selenium Grid on MAC server


Selenium Grid setup instructions are available on selenium site (http://selenium-grid.seleniumhq.org/get_started.html)


If java JDK is not setup, setup by including path in the system variables. Setup ANT path.


Go at the root of selenium grid directory and validate your installation:
$ cd selenium-grid-1.0
$ ant launch-hub
 
Step 5:Create scripts to start and stop GRID.
Shell script to start GRID
$ cd selenium-grid-1.0
$ ant launch-hub
Shell script to stop GRID
curl -d action=shutdown http://localhost:4444/lifecycle-manager

Step 6:Setup Selenium RC's on VM's and include RC's in the startup and run RC's on background.


Create Batch script to individual RC on VM's

Here is the sample Batch script (.bat)

cd C:\selenium-grid-1.0.8

ant -Dport=5590 -Dhost=1.2.3.4 -DhubURL=http://2.3.4.5:4448 -Denvironment="Firefox on Windows" -DseleniumArgs="-firefoxProfileTemplate \"C:\Users\test\AppData\Roaming\Mozilla\Firefox\Profiles\nlw66qbe.default"\" launch-remote-control


Step7: Create VBS script to run RC in the background. Give the RC batch file path in the VBS script.

Set WshShell = WScript.CreateObject("WScript.Shell")
obj = WshShell.Run("C:\GRID-RC.bat", 0)
set WshShell = Nothing


Include VBS file in the startup.

No comments:

Post a Comment