Few months back my company placed me in a java project. I wanted to work with some automation tool not exactly play back and recording. There for I tried my hand in selenium RC. Recently I successfully managed to install RC with
I have seen many of us seeking help to configure RC in their project. All they want to run very first test case. for that, I decided to write some thing which may help to begin with the very first etst case in RC.
Here in my article I will explain how to configure RC with
I am assuming that you are good in using IDE record and playback.
So once you done your recording with IDE convert your recorded script in java. for this click on OPTIONS->FORMAT and choose java. save this test case as simple java file.
so you have your test case say test.java.
Now follow the steps to configure Rc and java client driver with
1- Download Selenium-RC from the SeleniumHQ downloads page and save this some where you want.
2- launch
3- Create a new java project (I guess you are aware of creating a new project in
4- Add external jar files. (from the location where you have already saved downloaded selenium rc)
5- Add your saved java file(which you have saved after recording in IDE) to this project
6- Now run this as Junit test
here I am giving some explanation which might help you to get the things easily.
This is the java code which i have recorded using IDE to test the search in Google.
import junit.framework.*;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
import com.thoughtworks.selenium.SeleneseTestCase;
public class test1 extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://www.google.co.in/", "*firefox");
}
public void testVishal() throws Exception {
selenium.open("/");
selenium.type("q", "vishal sachan");
selenium.click("btnG");
selenium.waitForPageToLoad("30000");
verifyTrue(selenium.isTextPresent("vishal sachan"));
}
}
Running your test in multiple browser:
You can now run this test in different browse by initializing the desired browser info like firefox, iexplorer, chrome..
setUp("http://www.google.co.in/", "*firefox") ;
I hope this will help you to get started with you very first test using selenium RC.
Good details for the learner. Really learner can start by taking help of this article...
ReplyDeletehi vishal,
ReplyDeleteYour article is really helpful
Thanks
Srinivas
ERROR SERVER EXCEPTION:Session id not be null or yet not be started
ReplyDeleteYours Naveen
ERROR SERVER EXCEPTION:Session id not be null or yet not be started
ReplyDeleteHow to get rid of the exception
if any details send me to my mail
youandnaveen@gmail.com
Hello Vishal,
ReplyDeleteI have one problem.I need to connect database with selenium RC.If you have any idea please let me know on gbchoudhari@gmail.com
thanks a lot.............:)
ReplyDeleteThanks all. Also sorry to them who need some help. I was little busy and out of selenium as working some other tool.
ReplyDeleteI will get back to you individually.
Hi Vishal,
ReplyDeleteNice article.
Can you please tell me "How to Run Selenium RC in different browsers one after the other (After executing the scripts in one browser(Firefox), need to run the same scripts in the other browser(IE)) using Java?"
Thanks & Regards
Sunil D
@ Su,
ReplyDeletesetUp("http://www.google.co.in/", "*firefox");
you can change ur script accordingly. like here i have used firefox. U can iether save multiple script with diff browser specification or change it at the time of execution.
This comment has been removed by a blog administrator.
ReplyDeleteNice
ReplyDeleteHow to run a realtime java web project in selenium RC creating the build?
ReplyDeleteHow to run a realtime java web project in selenium RC creating the build?
ReplyDeleteCONSULTING, not Cunsulting!!
ReplyDeleteDipak, London.
@ Deepak, Thanks a lot!
ReplyDeletehi vishal,
ReplyDeleteI am getting the following errors-
com.thoughtworks.selenium.SeleniumException: Timed out after 30000ms
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:100)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:94)
at com.thoughtworks.selenium.DefaultSelenium.waitForPageToLoad(DefaultSelenium.java:647)
at test1.testVishal(test1.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:228)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Can you help me
really a nice blog.......thanks vishal as it helped me a lot.
ReplyDeleteAlso want to know something about selenium2.0 that how can we run test cases using maven project.