Please help me in working with (Selenium+Junit)

8 views
Skip to first unread message

Buntty

unread,
Oct 27, 2008, 9:41:27 AM10/27/08
to selenium-users...@googlegroups.com
Hi Friends,
                  I am using win-xp, I have down loded that Selenium IDE, RC.

  I recorded  script using selenium IDE, and then I want ot parameterized that In Selenium RCwith help of Junit.

Before that I took that script default generated in the [http://selenium-rc.openqa.org/tutorial.html]  Scrpit

{font:style=color: #000000;}import com.thoughtworks.selenium.*;{font}
{font:style=color: #000000;}import junit.framework.*;{font}
{font:style=color: #000000;}public class GoogleTest extends TestCase {{font}
{font:style=color: #000000;}    private Selenium browser;{font}
{font:style=color: #000000;}    public void setUp() {{font}
{font:style=color: #000000;}        browser = new DefaultSelenium("localhost",{font}
{font:style=color: #000000;}            4444, "*firefox", "[http://www.google.com|http://www.google.com/]");{font}
{font:style=color: #000000;}        browser.start();{font}
{font:style=color: #000000;}    }{font}
{font:style=color: #000000;}    {font}
{font:style=color: #000000;}    public void testGoogle() {{font}
{font:style=color: #000000;}        browser.open("[http://www.google.com/webhp?hl=en]");{font}
{font:style=color: #000000;}        browser.type("q", "hello world");{font}
{font:style=color: #000000;}        browser.click("btnG");{font}
{font:style=color: #000000;}        browser.waitForPageToLoad("5000");{font}
{font:style=color: #000000;}        assertEquals("hello world - Google Search", browser.getTitle());{font}
{font:style=color: #000000;}    }{font}
{font:style=color: #000000;}    {font}
{font:style=color: #000000;}    public void tearDown() {{font}
{font:style=color: #000000;}        browser.stop();{font}
{font:style=color: #000000;}    }{font}
{font:style=color: #000000;}}{font}


and store as *GoogleTest.java* then I want  to execute this  file.

but in the Command prompt it show that below error

+{font:style=font-family: comic sans ms,sans-serif;}C:\Program Files\Java\Junitfiles>javac GoogleTest.java{font}+
+{font:style=font-family: comic sans ms,sans-serif;}GoogleTest.java:1: package com.thoughtworks.selenium does not exist{font}+
+{font:style=font-family: comic sans ms,sans-serif;}import com.thoughtworks.selenium.*;{font}+
+{font:style=font-family: comic sans ms,sans-serif;}^{font}+
+{font:style=font-family: comic sans ms,sans-serif;}GoogleTest.java:4: cannot find symbol{font}+
+{font:style=font-family: comic sans ms,sans-serif;}symbol  : class Selenium{font}+
+{font:style=font-family: comic sans ms,sans-serif;}location: class GoogleTest{font}+
+{font:style=font-family: comic sans ms,sans-serif;}    private Selenium browser;{font}+
+{font:style=font-family: comic sans ms,sans-serif;}            ^{font}+
+{font:style=font-family: comic sans ms,sans-serif;}GoogleTest.java:6: cannot find symbol{font}+
+{font:style=font-family: comic sans ms,sans-serif;}symbol  : class DefaultSelenium{font}+
+{font:style=font-family: comic sans ms,sans-serif;}location: class GoogleTest{font}+
+{font:style=font-family: comic sans ms,sans-serif;}        browser = new DefaultSelenium("localhost",{font}+
+{font:style=font-family: comic sans ms,sans-serif;}                      ^{font}+
+{font:style=font-family: comic sans ms,sans-serif;}3 errors{font}+

after that i copied the C:\Program Files\Java\selenium-java-client-driver-1.0-beta-1\selenium-java-client-driver.jar in the "jre\lib" but still  it through same error

Please help me in this issue.


thanks
Buntty

Buntty

unread,
Oct 27, 2008, 11:11:24 AM10/27/08
to selenium-users...@googlegroups.com
Hi,
      Haroon,
                Thanks  it crreates the Googletest.class file but it shows some error, here it not possible to Paste the code so I am attachement the text file see that one.

\\ C:\Program Files\Java\Junitfiles>java junit.textui.TestRunner GoogleTest\\ .E\\ Time: 20.844\\ There was 1 error:\\ 1) testGoogle(GoogleTest)com.thoughtworks.selenium.SeleniumException: ERROR Serv\\ er Exception: sessionId should not be null; has this session been started yet?\\         at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandP\\ rocessor.java:73)\\         at com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:2\\ 34)\\         at GoogleTest.testGoogle(GoogleTest.java:12)\\         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\\         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)\\         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
FAILURES!!!\\ Tests run: 1,  Failures: 0,  Errors: 1


Please help in this issues  also

once againg thsnks to Haroon

Thanks
Buntty

Haroon

unread,
Oct 27, 2008, 11:18:58 AM10/27/08
to selenium-users...@googlegroups.com
Hi, Did you start the selenium server by the following command??

java -jar selenium-server.jar -interacive

The error shows that the test script is not able to communicate with the
Selenium server.

I hope this helps.

Thanks
Haroon

Buntty

unread,
Oct 27, 2008, 11:35:02 AM10/27/08
to selenium-users...@googlegroups.com
Hi,

    Haroon, I am sorry giving i{font:style=font-size: 12pt; color: #000000; font-family: Times New Roman;}nconvenient to u,{font}

{font:style=font-size: 12pt;}{font:style=color: #000000;}{font:style=font-family: Times New Roman;}{font:style=mso-spacerun: yes;} {font}1^st^ have followed that steps in the ur blog, {font:style=mso-spacerun: yes;} {font}Selenium server started and then through this error{font:style=mso-spacerun: yes;}  {font}please find this in the Selenium server command prompt. {font}{font}{font}

C:\Program Files\Java\selenium-server>java -jar selenium-server.jar -interactive
20:49:55.765 INFO - Java: Sun Microsystems Inc. 10.0-b23\\ 20:49:55.765 INFO - OS: Windows XP 5.1 x86\\ 20:49:55.765 INFO - v1.0-beta-1 [2201], with Core v1.0-beta-1 [1994]\\ 20:49:55.859 INFO - Version Jetty/5.1.x\\ 20:49:55.859 INFO - Started HttpContext[/selenium-server/driver,/selenium-server\\ /driver]\\ 20:49:55.859 INFO - Started HttpContext[/selenium-server,/selenium-server]\\ 20:49:55.859 INFO - Started HttpContext[/,/]\\ 20:49:55.875 INFO - Started SocketListener on 0.0.0.0:4444\\ 20:49:55.875 INFO - Started [org.mortbay.jetty.Server@32c41a]\\ Entering interactive mode... type Selenium commands here (e.g: cmd=open&1=http:/\\ /www.yahoo.com)\\ 20:50:29.140 INFO - Checking Resource aliases\\ 20:50:29.140 INFO - Command request: getNewBrowserSession[*Iexplore, [http://www].\\ google.com] on session null\\ 20:50:29.140 INFO - creating new remote session\\ 20:50:29.171 WARN - POST /selenium-server/driver/ HTTP/1.1\\ java.lang.RuntimeException: Browser not supported: *Iexplore
Supported browsers include:\\   *iexplore\\   *konqueror\\   *firefox\\   *mock\\   *pifirefox\\   *piiexplore\\   *chrome\\   *safari\\   *opera\\   *iehta\\   *custom
        at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.br\\ owserNotSupported(BrowserLauncherFactory.java:113)\\         at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.ge\\ tBrowserLauncher(BrowserLauncherFactory.java:93)\\         at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSessi\\ on(BrowserSessionFactory.java:307)\\         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)\\ 20:50:29.203 INFO - Command request: open[http://www.google.com/webhp?hl=en, ] o\\ n session null\\ 20:50:29.203 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:50:29.218 INFO - Got result: ERROR Server Exception: sessionId should not be\\ null; has this session been started yet? on session null\\ 20:50:29.234 INFO - Command request: testComplete[, ] on session null\\ 20:50:29.234 INFO - Got result: OK on session null

Buntty

unread,
Oct 29, 2008, 2:56:17 AM10/29/08
to selenium-users...@googlegroups.com
{font:style=font-size: 10pt; color: #333333; font-family: Arial;}Hi Haroon,{font}
     
{font:style=font-size: 10pt; color: #333333; font-family: Arial;}                Thanks small mistake make big problem,  this code executed.{font}
{font:style=font-size: 10pt; color: #333333; font-family: Arial;}  Then I have recorded some code using Selenium IDE, and exported to Selenium Rc, this file was saved as NewTest.java.{font}

{font:style=font-size: 10pt; color: #333333; font-family: Arial;}{font:style=mso-spacerun: yes}{font}Then I have complied that it create the .class file, but the problem is while run this program it will shows that some main method error{font:style=mso-spacerun: yes}  {font}below I have sown the code {font:style=mso-spacerun: yes}{font}and error also {font}
{font:style=font-size: 10pt; color: #333333; font-family: Arial;}{font:style=mso-spacerun: yes}{font}Please Resolve this Issue.{font}

{font:style=font-size: 10pt; color: #333333; font-family: Arial;}package com.example.tests;{font}
{font:style=font-size: 10pt; color: #333333; font-family: Arial;}import com.thoughtworks.selenium.*; \\ //import junit.framework.*; \\ import java.util.regex.Pattern;{font}
{font:style=font-size: 10pt; color: #333333; font-family: Arial;}public class NewTest extends SeleneseTestCase { \\ \\   private Selenium browser; \\   public void setUp() throws Exception { \\   setUp("[http://testersdesk.com/]", "*iexplore"); \\   } \\ public void testNew() throws Exception { \\   selenium.open("/"); \\   selenium.click("link=Login"); \\   selenium.type("username", "sample"); \\   selenium.type("password", "retest"); \\   selenium.click("//button[@type='submit']"); \\   selenium.click("link=Boundary Interactions Generator (BVA++)"); \\   selenium.click("//button[@type='submit']"); \\   selenium.click("link=Logout from this session"); \\   selenium.waitForPageToLoad("30000"); \\ } \\ }{font}

{font:style=font-size: 10pt; color: #333333; font-family: Arial;}I have complied with this command{font}
{font:style=font-size: 10pt; color: #333333; font-family: Arial;}javac -d . NewTest.java{font}

{font:style=font-size: 10pt; color: #333333; font-family: Arial;}then I haveexecuted with this command{font}

{font:style=font-size: 10pt; color: #333333; font-family: Arial;}java junit.textui.TextRunner NewTest{font}

{font:style=font-size: 10pt; color: #333333; font-family: Arial;}but it shows this error {font}
{font:style=font-size: 10pt; color: #333333; font-family: Arial;}
C:\Program Files\Java\Junitfiles>java junit.textui.TextRunner NewTest\\ Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/TextRunn\\ er\\ Caused by: java.lang.ClassNotFoundException: junit.textui.TextRunner\\         at java.net.URLClassLoader$1.run(Unknown Source)\\         at java.security.AccessController.doPrivileged(Native Method)\\         at java.net.URLClassLoader.findClass(Unknown Source)\\         at java.lang.ClassLoader.loadClass(Unknown Source)\\         at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)\\         at java.lang.ClassLoader.loadClass(Unknown Source)\\         at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Thnks
Bunntty.



{font}

Reply all
Reply to author
Forward
0 new messages