The coolest element nowadays is Selenium. You can even control it remotely.
What is Selenium?
Selenium is a testing tool for web applications that uses JavaScript and Iframes to run tests directly in a browser. There are several test tools based on this technology: Selenium Core, Selenium IDE, Selenium Remote Control, and Selenium on Rails.
The aforementioned Selenium Remote Control has become the tool I reach for when testing web applications. In fact, it is so useful that I hardly use HttpUnit any more.
What is Selenium Remote Control?
It is the remote control for Selenium. Duh. Ok, it really is that. A better, less obnoxious description is that Selenium Remote Control is a tool that allows us to test against the browser using our programming language of choice (in this case, Java).
How does Selenium Remote Control Work?
Selenium Remote Control depends on a server called—what else?—Selenium Server. The Selenium Server is capable of manipulating supported browsers and acts as a client-configured proxy between a browser and a website. This allows it to run JavaScript against a site.
How do I use Selenium Remote Control?
First, we’ll need to get the jars. With the jars, we’ll get the server and the client we’ll use for testing. (For this tutorial, the selenium-remote-control-0.9.1-SNAPSHOT nightly was used.) In the folder structure of the download, there are two jars that we want: selenium-server.jar in the “server” folder and selenium-java-client-driver.jar in the “java” folder.
We need to be able to start and stop the Selenium Server. We can do this at the command line:
Start:
java -jar selenium-server.jar
Stop:
http://localhost:4444/selenium-server/driver/?cmd=shutDown
To limit configuration and external dependencies, we can do this in our test code using the SeleniumServer class:
SeleniumServer server = new SeleniumServer(); server.start(); ... server.stop();
With the server running, we may now use a client:
Selenium selenium = new DefaultSelenium( String seleniumServerHost,
int seleniumServerPort,
String browserType,
String baseURL);
selenium.open("http://www.somesite.com/somePage.html");
selenium.stop();
An explanation of the variables in the DefaultSelenium constructor:
- seleniumServerHost is the where the Selenium Server is running. Typically, it is localhost.
- seleniumServerPort is the port on which the Selenium Server is listening. The default is 4444.
- browserType is the type of browser you want to use for testing. Common browser types are *firefox, *iexplore, *opera.
- baseURL is the base URL for the site you are testing. To adhere to the Same Origin Policy , the Selenium object created is tied to that particular URL and can only be used for that URL.
Now, just opening a page isn’t all that useful. We need to interact with the page. To do this, we use our selenium client’s methods with locators. For example:
selnium.click("link=Text For Some Link");
The string “link=Text For Some Link” is a locator. Most of operations involve locators that tie a Selenium command to elements in an HTML document.
Locators take the form of
“locatorType=argument”
A locator type can be an element id, an element name, an xpath expression, link text, and more.
A few examples:
selenium.click(“id=idOfThing”); //an id locator selenium.click(“name=nameOfThing”); //a name locator selenium.click(“xpath=//img[@alt='The image alt text']”); //an xpath locator selenium.click(“dom=document.images[56]” ); //a DOM locator selenium.click(“link=Test Page For Selenium”); //a link locator selenium.click(“css=span#firstChild”); //a css locator
Of course, there is more to Selenium than just clicking. But, the above gives you an idea of the types of locators, and how they are typically used with a method on the selenium object. We’ll explore other actions (methods) and locator types later.
The last step is to integrate the interaction and checking in a test. In this case, we’ll use JUnit to check the results of clicking a link. Note that the code below actually refers to a real link and page.
package com.bitmotif.seleniumexamples;
import com.thoughtworks.selenium.Selenium;
import com.thoughtworks.selenium.DefaultSelenium;
import junit.framework.TestCase;
import org.openqa.selenium.server.SeleniumServer;
public class ExampleTest
extends TestCase
{
private static final String MAX_WAIT_TIME_IN_MS = "60000";
private static final String BASE_URL = "http://www.bitmotif.com";
private Selenium selenium = new DefaultSelenium( "localhost",
4444,
"*firefox",
BASE_URL);
private SeleniumServer seleniumServer;
public void setUp()
throws Exception
{
seleniumServer = new SeleniumServer();
seleniumServer.start();
selenium.start();
}
public void tearDown()
throws Exception
{
selenium.stop();
seleniumServer.stop();
}
public void testClickingLink()
throws Exception
{
selenium.open(BASE_URL);
selenium.click("link=Test Page For Selenium Remote Control");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
String expectedTitle = "Bit Motif » Test Page For Selenium Remote Control";
assertEquals(expectedTitle, selenium.getTitle());
}
}
The only thing new in the code above is the waitForPageToLoad method. Sometimes an action such as clicking a link or submitting a form results in a page load. In order to make sure the new page is loaded before we attempt to do anything else, we use this method.
With that, we now have an example of using Selenium Remote Control as part of a test.
Why nobody says – where to place those java tests?
I get this file – and what next? I just can’t start it with “javac …” and “java …” (
Disappointed.
And what about using selenium-java-client-driver.jar? Does it REALLY required for the selenium java tests?
@P1F:
Regarding the selenium-java-client-driver.jar, it is need. As the name states, it’s where we get the client that talks to the selenium server.
Where to put the file, how to compile it, and run it are a really outside of what I wanted to talk about. You should be able to put the file in your favorite IDE or do it all at the command line if you want. Be sure to note the the package structure in the example (com.bitmotif.seleniumexamples).
Olá gostaria de saber como resolver o seguinte problema:
java.lang.RuntimeException: Could not contact Selenium Server; have you started it?
Catch body broken: IOException from cmd=getNewBrowserSession&1=*firefox&2=http%3A%2F%2Fwww.google.com -> java.net.ConnectException: Connection refused: connect
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:70)
at triton.testeSelenium.PrimeiroTeste.setUp(Unknown Source)
at junit.framework.TestCase.runBare(TestCase.java:125)
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:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
pois estou tentando criar o teste no eclipse numa classe java e não consigo executar o teste.
Por favor, me ajudem.
P1F,
I would recommend using an IDE such as Eclipse and placing tests inside a test source folder. Using JUnit, you can run these tests in quite a few different ways. Any basic JUnit tutorial can help you with this.
pjberry,
Excellent article. Well done.
perogi.
thanks for this tutorial… I’m new in selenium and i want to explore more on it… keep up the good work…
It’s a good tutorial, good easy language and good subject ( relevant
)..
However how do you write the long testing code for sites, i mean manually coding selenium.click(link), verify…etc. So do you always open the website, save the links and text to test and then code them in your code? Isn’t their a better way to do..
I try to record my tests using IDE, and then export them as Java classes where I can copy the selenium click/verify etc. commands into my java code, do you think that’s the best way?
Also do you have to create a new file for each test? If so, if you want to run them together (assume 10 classes, ExampleTest1, ExampleTest2,…,ExampleTest10 ), how do you do so ??
Thanks
Well its quite nicely described, Thumbs Up !!!! i would suggest you to please demonstrate some more scenarios with the help of examples showing regularly used features of Selenium.
Good Luck.
QUICK AND DIRTY for beginners:
Use selenium from jUnit Create a AllTests class that extends TestCase from jUnit framework.
Then make a wrapper that does the GLOBAL setup for all the tests (starts the browser).
Do not start the server from your java code if you run the remote control on another machine, else start it in your global setup
Organize your test cases in to test suites and feed the suites to the framewrok.
Note that you can do setUp() and tearDown() on different levels, such as GLOBAL (see example below), per test suite and per test case.
GLOBAL setup is nice when you are testing as a user that is “logged in” to your web app
(You do not want to stop / start a browser and login in and out if you are running a session where your “user” has to be logged in.)
##########################################################
## GLOBAL SET UP EXAMPLE
package com.alexandern.selenium;
import com.thoughtworks.selenium.Selenium;
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;
/**
* @author Alexander N
*/
public class AllTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(TestCaseOne.class); // your classes that extend jUnit TestCase
suite.addTestSuite(TestCaseTwo.class);
suite.addTestSuite(TestCaseThree.class);
TestSetup wrapper = new TestSetup(suite) {
protected void setUp() {
oneTimeSetUp();
}
private void oneTimeSetUp() {
Settings.loadProperties();
PrepareDatabase.blowAwayDatabase();
RC.initBrowser();
}
private void oneTimeTearDown() {
RC.stopBrowser();
}
protected void tearDown() {
oneTimeTearDown();
}
};
return wrapper;
}
public static void main(String arg[]) {
TestRunner.run(suite());
}
}
##########################################################
## a simple test case example
This test case is checking the menu that user see when
logged in to my web app. It clicks on admin menu links and
verifies that it got to the correct administration page.
You can extrapolate from that.
package com.tome.selenium.mytests
// custom RemoteController class stores objects used by all
// tests, err such as browser instance…
import com.tome.selenium.RC;
import com.thoughtworks.selenium.Selenium;
import junit.framework.TestCase;
import org.testng.annotations.BeforeTest;
public class TestAdminMenu extends TestCase {
Selenium selenium;
// MAKE SURE YOU NAME YOUR METHODS STARTING WITH WORD test
// like: testSomething if you want to use jUnit framework
@BeforeTest
public void setUp() {
// grab the browser you have started in the
// global setup and stored in the RC class you created
// see RC class below
selenium = RC.getBrowser();
}
public void testAdminResumeLink() {
selenium.click(“link=Resume”);
assertTrue(selenium.isTextPresent(“ES_RESUME”));
}
public void testAdminApplyChangesLink() {
selenium.click(“link=Apply Changes”);
assertTrue(selenium.isTextPresent(“Applying your changes…”));
}
public void testAdminSignOutLink() {
selenium.click(“link=Sign Out”);
assertTrue(selenium.isTextPresent(“Your session is closed”));
Conditions.setIsLoggedIn(false);
}
}
#############################################################
## RC (RemoteController) class, store stuff you will use in
## all your tests. Your browser instance is a good example.
## (Else you will be starting and stopping brwser for each
## test case
// custom settings class, read in some configs for your
// tests from a properties file blah blah blah use your
// imagination
import com.tome.selenium.setup.Settings;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
public class RC extends Settings {
private static Selenium browser;
public synchronized static void setBrowser(Selenium _browser) {
browser = _browser;
}
public synchronized static Selenium getBrowser() {
return browser;
}
ppublic synchronized static void stopBrowser() {
browser.stop();
}
public synchronized static void initBrowser() {
if (browser == null) {
browser = new DefaultSelenium(“localhost”, 4444, EXPLORER, APP_URL);
browser.start();
browser.setSpeed(EXECUTION_SPEED_NORMAL);
}
}
}
If you do not like jUnit (you must be mad! jUnit is awesome) you can jar up your
tests and just just all them from command line as any command line app.
Of cause if you see:
java.lang.RuntimeException: Could not contact Selenium Server; have you started it?
this means you have not started the selenium server.
you can start it from the command line: like this:
java -jar selenium-server.jar
(provided you have your JAVA_HOME and the rest of the stuff setup properly)
Hi all,
I am using selenium-rc,
No i want to config and starting selenium-java-client-driver. but i tried in many time but failed/
Please give me step by step if you had done it. Thanks
thanks for this tutorial… Can you put some examples using CSS.
Thanks in advance
You might want to mention to your users that the JBoss server uses port 4444 for its its “JRMPInvoker” mbean. Anybody trying your steps on JBoss 4.2.3GA would have to adjust this port to avoid conlicting with the selenium-server port.
Thanks a lot for the effort. I am familiar w/ selenium. Run into your blog while searching for the right xpath to click an image. thanks again. Folks like you make the world better
[20:03:45.931 INFO - Java: Sun Microsystems Inc. 11.3-b02
20:03:45.947 INFO - OS: Windows XP 5.1 x86
20:03:45.947 INFO - v1.0-beta-1 [2201], with Core v1.0-beta-1 [1994]
20:03:46.040 INFO – Version Jetty/5.1.x
20:03:46.056 INFO – Started HttpContext[/selenium-server/driver,/selenium-server
/driver]
20:03:46.056 INFO – Started HttpContext[/selenium-server,/selenium-server]
20:03:46.056 INFO – Started HttpContext[/,/]
20:03:46.072 INFO – Started SocketListener on 0.0.0.0:4444
20:03:46.072 INFO – Started org.mortbay.jetty.Server@e89b94
20:03:50.556 INFO – Checking Resource aliases
20:03:50.572 INFO – Command request: getNewBrowserSession[*chrome, https://stagi
ng.skytap.com] on session null
20:03:50.572 INFO – creating new remote session
20:03:50.744 INFO – Allocated session 3e031a4044324f3b8faf086f1bf4aac1 for https
://staging.skytap.com, launching…
20:03:50.806 INFO – Preparing Firefox profile…
20:04:11.666 WARN – POST /selenium-server/driver/ HTTP/1.1
java.lang.RuntimeException: Firefox refused shutdown while preparing a profile
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.wai
tForFullProfileToBeCreated(FirefoxChromeLauncher.java:290)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.lau
nch(FirefoxChromeLauncher.java:143)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.lau
nchRemoteSession(FirefoxChromeLauncher.java:329)
at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSessi
on(BrowserSessionFactory.java:312)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession
(BrowserSessionFactory.java:113)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession
(BrowserSessionFactory.java:78)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowse
rSession(SeleniumDriverResourceHandler.java:653)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(Se
leniumDriverResourceHandler.java:410)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleComman
dRequest(SeleniumDriverResourceHandler.java:388)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(Selen
iumDriverResourceHandler.java:135)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.http.HttpServer.service(HttpServer.java:909)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
244)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher$Fil
eLockRemainedException: Lock file still present! C:\DOCUME~1\ADMINI~1\LOCALS~1\T
emp\customProfileDir3e031a4044324f3b8faf086f1bf4aac1\parent.lock
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.wai
tForFileLockToGoAway(FirefoxChromeLauncher.java:247)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.wai
tForFullProfileToBeCreated(FirefoxChromeLauncher.java:288)
… 18 more
20:04:11.681 INFO – Command request: open[/default/login, ] on session null
20:04:11.681 ERROR – Exception running command
java.lang.NullPointerException: sessionId should not be null; has this session b
een started yet?
at org.openqa.selenium.server.FrameGroupCommandQueueSet.getQueueSet(Fram
eGroupCommandQueueSet.java:199)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(Se
leniumDriverResourceHandler.java:535)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleComman
dRequest(SeleniumDriverResourceHandler.java:388)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(Selen
iumDriverResourceHandler.java:135)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.http.HttpServer.service(HttpServer.java:909)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
244)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
20:04:11.697 INFO – Got result: ERROR Server Exception: sessionId should not be
null; has this session been started yet? on session null]
I am getting the above error can any one why is this? I m using selenium RC and firefox browser
Kevin St. Clair thanks a lot! lol, i had jboss running and tried starting selenium server, but it said that 4444 was already in use so i killed the process running it, then tried running a test, testing something on jboss and got a weird error:
Exception running ‘open ‘command on session null
i had killed jboss, not knowing it =) no wonder why my test then failed =)
nick
I like to test with two sessions/two browsers with selenium. But when I create two sessions, it doesn’t work well… Do you have idea how I can do that?
Hi Anonymous Lee,
Thank you! I have been looking at how to run test cases with a single browser instance for a day but with no luck. Your code gave me hints on how to do it.
Thanks Anonymous Lee,
For sharing your Selenium beginner framework. It was really useful!
what is Settings.LoadProperties(); expected to do in the above example? Also in the RC class, “import com.tome.selenium.setup.Settings;” what should i do to make it work? i’m not that familiar with java. so i might be missing something here.
I followed all the instructions correctly even though I am getting error mentioned below:
com.thoughtworks.selenium.SeleniumException: Internal Server Error
at com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponse(HttpCommandProcessor.java:124)
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:82)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:68)
at com.thoughtworks.selenium.DefaultSelenium.setContext(DefaultSelenium.java:542)
at com.thoughtworks.selenium.SeleneseTestCase.setUp(SeleneseTestCase.java:126)
at com.example.tests.NewTest1.setUp(NewTest1.java:11)
at junit.framework.TestCase.runBare(TestCase.java:125)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:71)
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:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:79)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Please can anybody tell me the reason for this error.
Hi,
I am new learner of using selenium Rc, i am trying to open http://www.google.com webpage and trying to enter some data in the search field.
i am trying to do this by writing code in java, i am able to open a webpage but unable to enter text in the search field.
my code:
import com.thoughtworks.selenium.*;
public class google {
DefaultSelenium selenium = new DefaultSelenium(“localhost”, 4444, “*iexploreproxy”,
“http://www.google.com/”);
public void test (){
try{
selenium.start();
selenium.open(“http://www.google.com”);
selenium.waitForPageToLoad(“100″);
selenium.type(“q”,”test”);
selenium.click(“xpath=//form/table[1]/tbody/tr[1]/td[2]/input[4]“);//(i have no idea why this step is?)
selenium.click(“btnG”);
selenium.waitForPageToLoad(“100″);
}
catch (Exception E){System.out.println(E);}
selenium.stop();
}
public static void main(String[] args) {
new google().test();
}
}
Plz help me out.
Thanks
Kavitha
The shutdown command mentioned in the original post –
http://localhost:4444/selenium-server/driver/?cmd=shutDown
- returns an error because it wants the session id. However, when starting from a bat script using the java -jar command, the session id is not returned. Is there a command that returns the current session id, or a way to stop the server that doesn’t require the session id?
While running the test script using Selenium RC – Java from eclipse (having plugin testng) i am getting the below error – (please let me know how can i resolve it).
[Parser] [WARN] Unknown value of attribute ‘parallel’ at suite level: ”.
[Parser] Running:
D:\Selenium_FW\test1\temp-testng-customsuite.xml
FAILED CONFIGURATION: @BeforeClass setup
java.lang.RuntimeException: Could not contact Selenium Server; have you started it on ‘localhost:4444′ ?
Read more at http://seleniumhq.org/projects/remote-control/not-started.html
Connection refused: connect
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:86)
at googletest.setup(googletest.java:10)
I have a machine running the selenium rc server, and im wanting to use another computer to run the driver. Both computers can communicate with each other already… How would you set that up?
Thanks!
Hi,
I am getting following error while running Selenium RC test cases using JUnit
com.thoughtworks.selenium.SeleniumException: XHR ERROR: URL = http://www.google.com/ Response_Code = 403 Error_Message = Forbidden
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)
at com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:353)
at com.testscripts.NewTest.testNew(NewTest.java:18)
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:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:212)
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:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
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)
Hi Motif,
Can you share the “Class Settings” definition which is extended by Class RC.
Regards
Sai
Hi,
I am getting following error while running Selenium RC test cases using JUnit
com.thoughtworks.selenium.SeleniumException: ERROR: There were no alerts
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
at
Following is script:-
package com.testscripts;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;
public class StatusUpdate extends SeleneseTestCase {
public void setUp() throws Exception {
setUp(“http://192.168.1.145″, “*iexplore”);
}
public void testStatusUpdate() throws Exception {
selenium.open(“/b/bmnoframe_login?pagewanted=/b/status”);
selenium.type(“username”, “fly2″);
selenium.type(“password”, “fly2″);
selenium.click(“signin”);
selenium.waitForPageToLoad(“30000″);
selenium.click(“link=Select None”);
selenium.click(“service[]“);
selenium.type(“status”, “New Updated status”);
selenium.click(“savepage”);
//selenium.waitForPageToLoad(“30000″);
assertEquals(“Your status has been updated.”, selenium.getAlert());
}
}
Please help me out.
Regards,
Krp
Hi,
I have created a selenium browser instance and logged in. Now i need to open a tab or another browser instance with the same session id as that of above. This is required to test SSO (Single sign on).
In google search i didn’t get the helpful info. So i am posting here.
Best Regards
saimadhu
can anybody help me for the Datadriven framework designing for Selenium RC in Java.
Thanks in Advance.
I need some examples in java eclipse and testng. how to use excel data in java code… send your feedback quickly.
I can start the selenium server by double clicking on the selenium-server.jar. But its not possible to stop the server using command prompt. I tried different ways (including http://localhost:4444/selenium-server/driver/?cmd=shutDown) to stop the server and all are failed. How can we stop the selenium server using command prompt?
Hi,
I am facing a error,while running the code.
“WARNING: Failed to start: SocketListener0@0.0.0.0:4444″
Hi …
I am having a suite which has 1 script that sets several variables that are referred in the test cases (html files). I am able to run the suite successfully within the IDE.
But when tried to run the suite using the command line option, I do not see these variables being set.
Any suggestions?
Thanks
Anil
To stop the selenium server use the following url:
http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer
[...] http://www.bitmotif.com/selenium/selenium-remote-control-for-java-a-tutorial/ [...]