Monday, February 22, 2010

Selenium RC configuration for Java

Few months back, I was trying to run selenium script with Selenium RC Java. Initially I faced few issues to configure the classpath settings. We need to pass the proxy details, if the net connection is based on proxy. I created three batch scripts to run the server and client. You should have latest java version. For more info about Selenium RC, check out Selenium RC documentation .

Selenium Server to start with proxy
Here user can set the username and password for proxy connection. Checkout java options to do that.

REM ******************************************** REM To Run Selenium server REM Author: Palani Selvam REM ******************************************** REM Selenium server path set SeleniumServer=D:\Selenium_trial\tool\selenium-remote-control-0.9.2\selenium-server-0.9.2 REM to run the Selenium server with proxy d: cd %SeleniumServer% java -Dhttp.proxyHost=proxy.mycompany.com -Dhttp.proxyPort=8080 -jar selenium-server.jar

Selenium Server to start without proxy
It will be useful for non-proxy connection.
REM ******************************************** REM To Run Selenium server REM Author: Palani Selvam REM ******************************************** REM Selenium server path set SeleniumServer=D:\Selenium_trial\tool\selenium-remote-control-0.9.2\selenium-server-0.9.2 REM to run the Selenium server without proxy d: cd %SeleniumServer% java -jar selenium-server.jar

To run the Selenium client
Below I have given the batch script to run the GetAllStockQuotes.java. Source code is available at Indian Stock Quotes through Selenium

REM ******************************************** REM To Run Selenium client (Java). Also sets path and classpath REM Author: Palani Selvam REM ******************************************** REM to set class path and path env variables to run selenium set javaClientPath=D:\Selenium_trial\tool\selenium-remote-control-1.0.1\selenium-java-client-driver-1.0.1 Set javaClientJars=%javaClientPath%\selenium-java-client-driver.jar REM JUnit jar Set jUnitJars=D:\java\JUnit\junit46.jar REM Selenium Script (Java) dir path set Stockspath=D:\Selenium_trial REM Setting classpath set classpath=%classpath%;%javaClientJars%;%jUnitJars%;%Stockspath%\classes; d: cd %Stockspath% REM Compiling test scripts Selenium-java code javac -d classes GetAllStockQuotes.java REM Running the test scripts java junit.textui.TestRunner com.palani.tests.GetAllStockQuotes

For more details of Selenium tools configuration, you can refer 5 Minute Guide To Selenium IDE and Selenium Remote Control (Java) Test Tools

3 comments:

vijay said...

Hi,
I want to automate the defect loging procedure. Currently we are manually loging issue in JIRA. I want to do automation of whole process like, when a issue is find during script running.. it will automatically get logged in JIRA with screenshot attachment and steps.

For above I need your help. I searched on web, but didnt find any plugin for JIRA in silktest.

I hope u will help me out of this issue. this is my email id vijayitest@gmail.com. I am looking for ur reply. Thanks in advance.

Dreamer said...

Hi

Have you tried handling SSL Ceritficate requests by browsers ?

The online tutorails dont seem to help me.

I need to automate a HTTPS enabled web app and I am stuck at the first page itself :(

Pls see if you can help me out on this.

Thanks
Anish (aniaswin@gmail.com)

Palani Selvam said...

Hi Anish,
I hope, this problem can be solved and check with selenium documentation.