UNABLE TO RUN JAVA file with selenium RC

36 views
Skip to first unread message

Sandeep Neema

unread,
Jul 21, 2010, 8:31:46 AM7/21/10
to Selenium Users
hello friends,
I am new to selenium tool. I recorded a script with selenium IDE and
save that script in java(JUNIT). The file is as follow:

import junit.framework.*;
import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

public class First extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://www.google.co.in/", "*chrome");
}
public void testUntitled() throws Exception {
selenium.open("/");
selenium.type("q", "selenium");
selenium.click("//input[@value='Google Search' and
@type='button']");
selenium.waitForPageToLoad("30000");
selenium.click("link=Selenium web application testing system");
selenium.waitForPageToLoad("30000");
selenium.click("link=Documentation");
selenium.waitForPageToLoad("30000");
}
public static Test Suite(){
return new TestSuite(First.class);
}
public static void main(String args[]){
junit.textui.TestRunner.run(Suite());
}
}

I have compile the java file and it is showing no error. After that
i started the selenium server and write a command on the terminal
$ java First
and it is showing the following error.. Please help me to remove this
error.


[root@01HW278704 TestCases]# java First
.E
Time: 39.909
There was 1 error:
1) testUntitled(First)com.thoughtworks.selenium.SeleniumException:
Timed out after 30000ms
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:
335)
at First.testUntitled(First.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at
com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:
212)
at First.main(First.java:24)

FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1

Nusrat Nilofer

unread,
Jul 21, 2010, 10:54:12 AM7/21/10
to seleniu...@googlegroups.com
try replacing the waitForPagetoLoads with appropriate waitForElementPresent..


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Sandeep Neema

unread,
Jul 22, 2010, 2:49:13 AM7/22/10
to Selenium Users
hey i am new to this so can you tell me where i can place
waitForElementPresent in the above shown script so as toremoe the
error. But, the main thing is that if i correct this error also then
still my firefox will open or not. Because when i run the command(java
First) the browser gets open but it shows nothing and shut down. and
above error i have told you before is shown in the terminal.

On Jul 21, 7:54 pm, Nusrat Nilofer <nnilo...@gmail.com> wrote:
> try replacing the waitForPagetoLoads with appropriate
> waitForElementPresent..
>
> > selenium-user...@googlegroups.com<selenium-users%2Bunsu...@googlegroups.com>
> > .

Nusrat Nilofer

unread,
Jul 22, 2010, 2:54:20 AM7/22/10
to seleniu...@googlegroups.com
try replacing your code with the following:

selenium.open("/");
               selenium.type("q", "selenium");
selenium.waitForElementPresent("//input[@value='Google Search' and

@type='button']");
               selenium.click("//input[@value='Google Search' and
@type='button']");
               selenium.waitForElementPresent("link=Selenium web application testing system");

               selenium.click("link=Selenium web application testing system");
               selenium.waitForElementPresent("link=Documentation");
               selenium.click("link=Documentation");
             

so the basic funda is before performing any click/select/type operation on any locator it is advised to use waitForElementPresent for that locator.
try with this code if it still shows error then might be you will have to seTimeout to more then 30000(default)

To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Sandeep Neema

unread,
Jul 22, 2010, 3:18:53 AM7/22/10
to Selenium Users
hey friend it is still showing the error in the terminal without
launching the firefox.

[root@01HW278704 TestCases]# java Second
.E
Time: 0.049
There was 1 error:
1) testUntitled(Second)java.lang.RuntimeException: Could not start
Selenium session: Internal Server Error
at
com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:
89)
at
com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:
123)
at
com.thoughtworks.selenium.SeleneseTestBase.setUp(SeleneseTestBase.java:
104)
at
com.thoughtworks.selenium.SeleneseTestCase.setUp(SeleneseTestCase.java:
78)
at Second.setUp(Second.java:7)
at
com.thoughtworks.selenium.SeleneseTestCase.runBare(SeleneseTestCase.java:
212)
at Second.main(Second.java:26)
Caused by: com.thoughtworks.selenium.SeleniumException: Internal
Server Error
at
com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:
97)
at
com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:
168)
at
com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:
104)
at
com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:
86)
at
com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:
262)
at
com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:
223)
at
com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:
81)
... 16 more

FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1


To start the server i have write
java -jar selenium-server.jar -port 8081

But, still dont running in firefox. Please help me asap.








On Jul 22, 11:54 am, Nusrat Nilofer <nnilo...@gmail.com> wrote:
> try replacing your code with the following:
>
> selenium.open("/");
>                selenium.type("q", "selenium");
> selenium.waitForElementPresent("//input[@value='Google Search' and
> @type='button']");
>                selenium.click("//input[@value='Google Search' and
> @type='button']");
>                selenium.waitForElementPresent("link=Selenium web application
> testing system");
>                selenium.click("link=Selenium web application testing
> system");
>                selenium.waitForElementPresent("link=Documentation");
>                selenium.click("link=Documentation");
>
> so the basic funda is before performing any click/select/type operation on
> any locator it is advised to use waitForElementPresent for that locator.
> try with this code if it still shows error then might be you will have to
> seTimeout to more then 30000(default)
>
> > <selenium-users%2Bunsu...@googlegroups.com<selenium-users%252Buns...@googlegroups.com>

Nusrat Nilofer

unread,
Jul 22, 2010, 3:21:54 AM7/22/10
to seleniu...@googlegroups.com
why have you use port 8081, any specific reason?
and also tell me the commands in Second.java:26 and Second.java:7


To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Sandeep Neema

unread,
Jul 22, 2010, 3:57:48 AM7/22/10
to Selenium Users

No, i use port 8081 because it is showing following error:
12:47:24.755 WARN - Failed to start: SocketL...@0.0.0.0:4444
Exception in thread "main" java.net.BindException: Selenium is already
running on port 4444. Or some other service is.
at
org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:
399)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:
234)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:
198)

the commands you ask me are:
Second.java:7===> setUp("http://www.google.co.in/",
"*firefox");
Second.java:26===> junit.textui.TestRunner.run(Suite());

On Jul 22, 12:21 pm, Nusrat Nilofer <nnilo...@gmail.com> wrote:
> why have you use port 8081, any specific reason?
> and also tell me the commands in Second.java:26 and Second.java:7
>
> > > > <selenium-users%2Bunsu...@googlegroups.com<selenium-users%252Buns...@googlegroups.com>
> > <selenium-users%252Buns...@googlegroups.com<selenium-users%25252Bun...@googlegroups.com>

Sandeep Neema

unread,
Jul 22, 2010, 3:59:51 AM7/22/10
to Selenium Users

No, i use port 8081 because it is showing following error:
12:47:24.755 WARN - Failed to start: SocketL...@0.0.0.0:4444
Exception in thread "main" java.net.BindException: Selenium is already
running on port 4444. Or some other service is.
at
org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:
399)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:
234)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:
198)

the commands you ask me are:
Second.java:7===> setUp("http://www.google.co.in/",
"*firefox");
Second.java:26===> junit.textui.TestRunner.run(Suite());

On Jul 22, 12:21 pm, Nusrat Nilofer <nnilo...@gmail.com> wrote:
> why have you use port 8081, any specific reason?
> and also tell me the commands in Second.java:26 and Second.java:7
>
> > > > <selenium-users%2Bunsu...@googlegroups.com<selenium-users%252Buns...@googlegroups.com>
> > <selenium-users%252Buns...@googlegroups.com<selenium-users%25252Bun...@googlegroups.com>

Nusrat Nilofer

unread,
Jul 22, 2010, 4:00:23 AM7/22/10
to seleniu...@googlegroups.com
but by default server uses port 4444

To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Sandeep Neema

unread,
Jul 22, 2010, 5:23:32 AM7/22/10
to Selenium Users

yeah by default server uses port 4444. Thats why i changed the port
because some apps is already using that port. so it is not a problem
that my server is running on port 8081.
The main problem is that my firefox is not opening when i run
===> java Second
it simply show the followin error:

[root@01HW278704 TestCases]# java Second
.E
Time: 0.052
Please if you can help me regarding how i can make my test case run
visible in firefox.

On Jul 22, 1:00 pm, Nusrat Nilofer <nnilo...@gmail.com> wrote:
> but by default server uses port 4444
>
> On Thu, Jul 22, 2010 at 1:27 PM, Sandeep Neema <neema.sand...@gmail.com>wrote:
>
>
>
> > No, i use port 8081 because it is showing following error:
> > 12:47:24.755 WARN - Failed to start: SocketListen...@0.0.0.0:4444
> > > > > > <selenium-users%2Bunsu...@googlegroups.com<selenium-users%252Buns...@googlegroups.com>
> > <selenium-users%252Buns...@googlegroups.com<selenium-users%25252Bun...@googlegroups.com>
>
> > > > <selenium-users%252Buns...@googlegroups.com<selenium-users%25252Bun...@googlegroups.com>
> > <selenium-users%25252Bun...@googlegroups.com<selenium-users%2525252Bu...@googlegroups.com>
>
> > > > > > > > .
> > > > > > > > For more options, visit this group at
> > > > > > > >http://groups.google.com/group/selenium-users?hl=en.
>
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google
> > > > Groups
> > > > > > "Selenium Users" group.
> > > > > > To post to this group, send email to
> > seleniu...@googlegroups.com.
> > > > > > To unsubscribe from this group, send email to
>
> ...
>
> read more »

Nusrat Nilofer

unread,
Jul 22, 2010, 5:25:57 AM7/22/10
to seleniu...@googlegroups.com
whats your firefox version?

To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Sandeep Neema

unread,
Jul 22, 2010, 5:40:07 AM7/22/10
to Selenium Users
Firefox version 3.5b4

On Jul 22, 2:25 pm, Nusrat Nilofer <nnilo...@gmail.com> wrote:
> whats your firefox version?
>
> ...
>
> read more »

Sandeep Neema

unread,
Jul 22, 2010, 5:41:32 AM7/22/10
to Selenium Users
I am using Selenium RC 1.0.3.


On Jul 22, 2:25 pm, Nusrat Nilofer <nnilo...@gmail.com> wrote:
> whats your firefox version?
>
> ...
>
> read more »

Nusrat Nilofer

unread,
Jul 22, 2010, 8:00:12 AM7/22/10
to seleniu...@googlegroups.com
i doubt that you have instantiated the selenium object with port no. 4444 because by default in SeleneseTestCase selenium object is instantiated with 4444 as port no.

> ...
>
> read more »

Reply all
Reply to author
Forward
0 new messages