Execute Selenium Test Using Eclipse

by seetaram on March 22, 2011

We already have configured Selenium Client Driver with Eclipse.  Now, copy the Selenium server into the SeleniumTests folder inside Eclipse-Workspace folder and then create “Selenium-server.bat file with the following code in it.  Below code should not be copied and pasted into the notepad as “-” (hyphen) is getting saved as a special character and does not get executed when you double click the .bat file.

cd F:Eclipse-WorkspaceSeleniumTests
java -jar selenium-server.jar –multiWindow

Type the above code into a text file (e.g. open notepad –> copy the above code) and then save it as Selenium-server.bat

Double Click and run the Selenium-server.bat.  Selenium server will start running in the command prompt.  Following figure shows the Selenium server execution.

executeSeleniumServer

Open Eclipse and create a Java Class as described below:

  1. Create a Java Project (e.g. SugarCRMTests – this already should have been created as it is described in the previous post)
  2. Under src –> create new package (Right click on src –> click package –> Give a name –> SugarCRMTests – this name can be anything as per your choice)
  3. Create new Java Class (Right click Package –> Click New –> Click Class –> give a name preferably SugarCRM)
  4. Copy and paste the below code into SugarCRM.java file and save (Overwrite the self-generated code when SugarCRM.java is created)

package sugarCRMTests;
import com.thoughtworks.selenium.*;

public class SugarCRM {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
DefaultSelenium selenium = new DefaultSelenium(“localhost”,4444,”*chrome”,”http://www.google.com”);
selenium.start();
selenium.windowMaximize();
SugarLogin(selenium);
SugarLogout(selenium);
}
public static void SugarLogin(DefaultSelenium selenium){
selenium.open(“http://127.0.0.1/sugarcrm/index.php?action=Login&module=Users”);
selenium.type(“user_name”, “admin”);
selenium.type(“user_password”, “admin123”);
selenium.click(“login_button”);
selenium.waitForPageToLoad(“30000”);
selenium.isTextPresent(“Home”);
selenium.waitForPageToLoad(“30000”);
}
public static void SugarLogout(DefaultSelenium selenium){
selenium.click(“link=Log Out”);
}

}

Above code is recorded using Selenium IDE and then exported into JUnit format as explained in the earlier post.

Click on Run menu –> Run As –> Java Application as shown in the following figure.

executeSeleniumTest

Execution of the above Selenium Test will open up two more firefox browser and starts the execution.

Note: Please provide me feedback through your valuable comments

{ 57 comments… read them below or add one }

Vikram March 23, 2011 at 12:45 pm

Excellent. Its terrific platform for the beginners. Such an easy and simple approach to explain it.
Looking for more topics.

Reply

seetaram March 23, 2011 at 1:11 pm

Thanks Vikram.. I expect more feedback from readers that will really help me improving the quality of articles on the blog

Reply

vikas June 30, 2011 at 6:24 am

Hi sir,
I am new to selenium, I want to know how to perametrize the test case in selenium ide , I have to perametrize the login form and registeration for of my application . can you please help me ………….

Reply

seetaram June 30, 2011 at 7:04 am

I dont think that learning how to parameterize with Selenium IDE will be helpful. Instead, visit my posts on “Setting up Selenium with Eclipse” and “Parameterization with Microsoft Excel & CSV file” that will be greatly helpful with respect to parameterizing the Selenium tests

Reply

cybage May 26, 2011 at 10:19 am

Hello sir,

Very good article.

I am not able to reproduce the selenium server in the command window as shown above.

I have performed the same steps as described but when i double click on .bar file, the window starts and disappears.

Please help me out.

Reply

seetaram May 31, 2011 at 7:24 am

file name should be .bat file not “.bar” as it is a “windows batch file” where we can specify multiple commands.

Step 1: Create a new text file

Step 2: Open the file and type in following code into it (D:\Workspace-Helios should be changed to the path where selenium-server.jar file is copied)

CD D:\Workspace-Helios
java -jar selenium-server.jar -multiWindow

(Don’t copy and paste as sometime it adds some special characters)

Step 3: Save it as “Selenium-server.bat”

Step 4: Still if you are not able to run, then execute both the commands in command prompt (Click Start -> Run ->cmd). If it is throwing any errors please let me know.

Reply

NagarjunReddy September 23, 2011 at 10:42 am

Excellent article. Looking for more article with examples.
Thanks alot.

Reply

seetaram September 23, 2011 at 11:44 am

Thanks a lot. Currently, I am writing even on VBScript and QTP. Hence, planning to dedicate at least two days in a week to write on Selenium.

Reply

Syam December 1, 2011 at 7:13 am

It’s really nice. Can you please include topics on how to execute scripts using Testng

Reply

seetaram December 2, 2011 at 5:06 am

Hi Syam,

I will definitely try to do that…..

–Seetaram

Reply

Bishnu January 31, 2012 at 3:07 pm

hi,
i did my first Selenium script according to the blog “Execute Selenium Test Using Eclipse”. But i am getting the following error. can anybody help me on this.

Exception in thread “main” java.lang.NoClassDefFoundError: com/google/common/base/Charsets
at com.thoughtworks.selenium.HttpCommandProcessor.getOutputStreamWriter(HttpCommandProcessor.java:149)
at com.thoughtworks.selenium.HttpCommandProcessor.getCommandResponseAsString(HttpCommandProcessor.java:176)
at com.thoughtworks.selenium.HttpCommandProcessor.executeCommandOnServlet(HttpCommandProcessor.java:118)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:101)
at com.thoughtworks.selenium.HttpCommandProcessor.getString(HttpCommandProcessor.java:275)
at com.thoughtworks.selenium.HttpCommandProcessor.start(HttpCommandProcessor.java:237)
at com.thoughtworks.selenium.DefaultSelenium.start(DefaultSelenium.java:98)
at SugarCRMTests.SugarCRM.main(SugarCRM.java:12)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Charsets
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)
… 8 more

Reply

seetaram February 4, 2012 at 3:02 am

Add Selenium server to class path

Reply

Felipe F. Fagundes May 15, 2012 at 10:12 pm

Thank’s, dude. That works for me.

Reply

aileen May 30, 2012 at 2:38 am

Hi, why we need to add the server.jar to the class path? I see most tutorials not mention this step.

Reply

seetaram June 7, 2012 at 2:48 pm

Remove the selenium server.jar from your class path you will only find out… 🙂

Abhijeet August 23, 2012 at 2:51 am

I had the same problem and i added selenium server jar and it started working fine. But do we need to add sever jar even if we use junit3??

P.S: Thanks, A Great article !!! am able to now run the scripts succesfully.

Reply

Manohar November 15, 2012 at 4:33 am

thanks, Even for me not it is working fine.

Vinodh G August 8, 2013 at 3:58 pm

Hi,

I am getting the same error as above and tried adding the selenium server to class path but getting the same error

Tried the below in cmd
C:\>echo %CLASSPATH%
V:\Selenium\selenium-server-standalone-2.34.0.jar

may be not adding in the right place. Can you please tell me how to add class path?

Regrads,
Vinodh G

Sanjeev February 7, 2012 at 12:04 pm

i am getting following error when the above code is executed

at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 8 more

Reply

Christina April 4, 2012 at 3:31 pm

import com.thoughtworks.selenium.*;
Where is come from?
Look like I miss some package?

Reply

seetaram April 16, 2012 at 12:40 pm

you need to add Selenium-java-client.jar file to eclipse build path

Reply

Som April 4, 2012 at 6:39 pm

After running the code, only instance of the firefox opens but the execution does not start. Can you please help?

Reply

seetaram April 16, 2012 at 12:36 pm

This might be browser compatibility issue…try to download the latest selenium server as well as java client and then run.. this will work fine….

Reply

Winter May 25, 2016 at 12:09 pm

A minute saved is a minute eaerdn, and this saved hours!

Reply

Sri June 25, 2012 at 6:33 pm

I am getting the below errror:
The constructor DefaultSelenium(String, String) is undefined.

Can someone help me please?

Reply

seetaram June 29, 2012 at 4:04 pm

Check the arguments for DefaultSelenium constructor.. and pass them accordingly…

Reply

Sri June 25, 2012 at 9:08 pm

When I execute “Selenium-server.bat” file I am getting the below Warning:
can anyone help me please?
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\SeleniumTests_Workspace>java -jar SeleniumTests\selenium-server-standalone-2.
24.1.jar
Jun 25, 2012 4:02:31 PM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
16:02:32.355 INFO – Java: Sun Microsystems Inc. 20.4-b02
16:02:32.355 INFO – OS: Windows 7 6.1 amd64
16:02:32.385 INFO – v2.24.1, with Core v2.24.1. Built from revision 17205
16:02:32.605 INFO – RemoteWebDriver instances should connect to: http://127.0.0.
1:4444/wd/hub
16:02:32.605 INFO – Version Jetty/5.1.x
16:02:32.605 INFO – Started HttpContext[/selenium-server/driver,/selenium-server
/driver]
16:02:32.605 INFO – Started HttpContext[/selenium-server,/selenium-server]
16:02:32.605 INFO – Started HttpContext[/,/]
16:02:32.655 INFO – Started org.openqa.jetty.jetty.servlet.ServletHandler@14d6a0
5e
16:02:32.655 INFO – Started HttpContext[/wd,/wd]
16:02:32.665 WARN – Failed to start: SocketListener0@0.0.0.0:4444
Exception in thread “main” java.net.BindException: Selenium is already running o
n port 4444. Or some other service is.
at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:4
83)
at org.openqa.selenium.server.SeleniumServer.boot(SeleniumServer.java:28
3)
at org.openqa.selenium.server.SeleniumServer.main(SeleniumServer.java:24
6)
at org.openqa.grid.selenium.GridLauncher.main(GridLauncher.java:54)

C:\SeleniumTests_Workspace>

*** When I did “netstat” on the port “4444” in my machine I see that port has no “ESTABLISHED” connections.

Reply

seetaram June 29, 2012 at 4:03 pm

To run the WebDriver Selenium tests you need not to run the Selenium server batch file.. Stop the Selenium server and then execute the script on eclipse… that should run fine…

Reply

Chirag June 26, 2012 at 3:41 pm

Hello Seetaram,

I am executing these two commands
-> cd Desktop\Selenium RC\Eclipse-Workspace\SeleniumTests
-> java -jar selenium-server-standalone-2.24.1.jar -multiWindow

I am getting following error while executing command on the command prompt.

Exception in thread “main” java.lang.UnsupportedClassVersionError: Bad version n
umber in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
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)

Please reply asap…

Reply

seetaram June 29, 2012 at 4:00 pm

Need to change the Java compiler version in Eclipse.. Go to properties.. and change the version…

Reply

Hari August 7, 2012 at 6:42 am

Hi,
I tried exporting a recorded script as junit4/remote control and copy pasted the exported code in to eclipse. But it shows an error selenium cannot be resolved to a variable and all commands with keyword selenium are shown as error. I have pasted the code below:-
package coralTests;
import com.thoughtworks.selenium.*;
public class Coral {

public void setUp() throws Exception {
selenium = new DefaultSelenium(“localhost”, 4444, “*chrome”, “http://192.168.0.50/”);
selenium.start();
}

public void testCoral() throws Exception {
selenium.open(“/coralms2/”);
selenium.click(“link=Register”);
selenium.waitForPageToLoad(“30000”);
selenium.select(“id=UserRoleId”, “label=Instructor”);
selenium.type(“id=CompanyName”, “Test Company”);
selenium.type(“id=CompanyRegistrationNumber”, “254”);
selenium.type(“id=Address1Postcode”, “560045”);
selenium.click(“//img[@onclick=\”findAddressBilling(‘DM72-EK19-EM86-YE59’)\”]”);
selenium.type(“id=Address0Address1Billing”, “Test companyh”);
selenium.type(“id=Address0TownBilling”, “Bengaluru”);
selenium.select(“id=UserTitle”, “label=Dr”);
selenium.type(“id=UserForename”, “Test”);
selenium.type(“id=UserSurname”, “name”);
selenium.type(“id=UserEmail”, “testinst@yopmail.com”);
selenium.type(“id=UserWorkTelephone”, “987456632154”);
selenium.click(“id=UserAgree”);
}

Reply

seetaram August 13, 2012 at 2:25 pm

Hi Hari,

Please browse the blog and find out how to setup the selenium with eclipse properly and then try this code, that should work fine. The reason being, the Selenium jar is not added to the project build path

Reply

Nusha September 4, 2012 at 11:22 am

Exception in thread “main” 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:104)
at SugarCRMTests.SugarCRM.main(SugarCRM.java:26)

How can i solve this error? I have added both selenium client jar and the standalone server jar to the build path. Created the bat file as well with the proper path.

Thank you for ur tutorials. 🙂

Reply

seetaram September 6, 2012 at 2:13 pm

Run Selenium server…. 🙂 thats it… You are getting this error because Selenium Server is not running….

Reply

Nusha September 7, 2012 at 12:53 pm

Below are the codes that I have saved in as .bat. So i just have to double click on it to start the server, right? I am confused with this selenium rc. and thanks you again for the rather fast reply! 🙂

CD C:\Users\anusha\Desktop\Junit
java -jar selenium-server-standalone-2.25.0.jar -multiWindow

Reply

Rasheed October 3, 2012 at 5:02 pm

Hello Seetaram. Happy to see your Blog. I hope its very nice site learn Selenium step by step. I have seen only Java automation using selenium. Do you have any post on C# selenium automation using web driver?.
Thanks a lot…

Reply

seetaram August 26, 2013 at 6:19 am

Not written using C# but I have worked on C# with NUnit that is pretty simple and same as Java with JUnit

Reply

Mohammad Muqthiyar October 8, 2012 at 4:29 pm

Please suggest me while running selenium rc, i am getting the following error msg:
Error:Could not find or load main class java-jar
Thanks in advance

Reply

Lior Katz November 19, 2012 at 7:36 am

Daer Sir,

First thanks soo much for the usefull site!!!
I am geeting the folowing errors trying to run the servers:

at javax.swing.plaf.basic.BasicTreeUI.paintRow(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI.paint(Unknown Source)
at javax.swing.plaf.ComponentUI.update(Unknown Source)
at javax.swing.JComponent.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JViewport.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.access$700(Unknown Source)
at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown

at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.Dialog$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown

at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown

at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown

at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

And when executing the script I am geeting the following error message

” throw new RuntimeException(“Could not contact Selenium Server; have you started it on ‘” +”

Can you please asist with the above?

Thanks so much

Lior

Reply

Arifa Batool December 19, 2012 at 6:17 am

Thanks a bunch. It was very helpful.

Reply

Lobo December 21, 2012 at 8:19 pm

I’m getting a lot of Syntax errors when copying/pasting the code, therefore it will not let me save or execute. Please help!

i.e.

Reply

Lobo December 21, 2012 at 9:00 pm

This works now when replacing all the quotation marks. Executed it, but not able to connect to http://127.0.0.1/sugarcrm/index.php?action=Login&module=Users.

Reply

surbhi January 19, 2013 at 4:33 am

hiee..m new to this sellenium..m front end developer… need to do front end testing…how i will integrate it with Ecllipse..

Reply

mahendar January 30, 2013 at 7:04 am

I trying to execute the following selenium IDE program in Eclipse using Junit but i am getting following errors,
Program:
package seleniumtests;
import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.regex.Pattern;

public class wiki {
private Selenium selenium;

@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium(“localhost”, 4444, “*chrome”, “http://www.wikipedia.org/”);
selenium.start();
}

@Test
public void testWiki() throws Exception {
selenium.open(“/”);
selenium.click(“css=strong”);
selenium.waitForPageToLoad(“30000”);
selenium.type(“id=searchInput”, “cognizant”);
selenium.click(“id=searchButton”);
selenium.waitForPageToLoad(“30000”);
selenium.click(“link=Hyderabad”);
selenium.waitForPageToLoad(“30000”);
selenium.click(“link=4th”);
selenium.waitForPageToLoad(“30000”);
}

@After
public void tearDown() throws Exception {
selenium.stop();
}
}

Errors:
I am getting error at Function “public void testwiki()”

Please go through the above program and provide a solution.

Reply

Saba Manzoor February 12, 2013 at 7:17 am

I am getting this error when rum my test case:

FAILED: myTest
java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:56)
at org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:79)
at org.openqa.selenium.firefox.FirefoxProfile.(FirefoxProfile.java:67)
at fortestingpackage.fortestingclass.myTest(fortestingclass.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:128)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1203)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1128)
at org.testng.TestNG.run(TestNG.java:1036)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
… 28 more

Reply

seetaram March 7, 2013 at 6:08 am

This looks like Java version compatibility issue… configure the proper JRE in the properties

Reply

Techy March 7, 2013 at 2:34 pm

Hi
I’m getting the following error, when I execute the script. Any ideas why. Thanks.

Exception in thread “main” java.lang.Error: Unresolved compilation problems:
Syntax error on tokens, ArgumentList expected instead
Syntax error on token “Invalid Character”, invalid Expression
Syntax error, insert “)” to complete ClassInstanceCreationExpression
Syntax error, insert “;” to complete BlockStatements

at eTraderPackage.SugarCRM.main(SugarCRM.java:13)

Reply

Techy March 7, 2013 at 4:12 pm

All sorted now…. 🙂 I got a bunch of errors because I didnt have serlenium server.jar added

Reply

Khyati March 19, 2013 at 6:28 pm

Hi,

I am getting the following error. Please help. Thank you!

Error: Could not find or load main class SugarCRMTests.SugarCRM

Reply

seetaram August 26, 2013 at 6:07 am

I think there is no main method written and you are trying to execute.

Reply

Sirisha April 3, 2013 at 11:49 am

Hello, I tried running the 2nd command but i’m getting “Unable to access jarfile selenium-server.jar”
I have set the selenium server in classpath
D:\Users\sirisha\Downloads\selenium-java-2.31.0\selenium-2.31.0\selenium-2.31.0\selenium-server-standalone-2.31.0

Can you please help me with this?

Reply

Akshata May 28, 2013 at 6:40 am

Hi Seetaram,

Its really a helpful post. Thanks for that.
I followed your steps. When I double clicked on .bat file, window opens and immediately disappears. I have not copy, pasted. Typed it.
Tried with command prompt also. It gave the below error
“Unable to access jar file selenium-server jar.
Could you please help me

Thanks in advance
Akshata

Reply

Akshata May 29, 2013 at 12:37 pm

Hi

The above problem was solved.

Reply

seetaram August 21, 2013 at 9:13 am

There is some error in your bat file, for example Java might be missing in your system. Try to execute the bat file from command line and see the error message and then fix it

Reply

Mangesh Kulkarni March 23, 2015 at 9:50 am

Please give me the solution.I did same as you and I got error

Below 3 lines are from bat file

E:\Workspace\OKI\src\TestCases>set path=”C:\Program Files\Java\jdk1.8.0_20\bin”

E:\Workspace\OKI\src\TestCases>set classpath=”E:\selenium-server-standalone-2.45
.0.jar”

E:\Workspace\OKI\src\TestCases>javac Case_CreateOPCO.java

Here is the output :

Case_CreateOPCO.java:5: error: package jxl.read.biff does not exist
import jxl.read.biff.BiffException;
^
Case_CreateOPCO.java:7: error: package org.junit does not exist
import org.junit.After;
^
Case_CreateOPCO.java:8: error: package org.junit does not exist
import org.junit.Before;
^
Case_CreateOPCO.java:9: error: package org.junit does not exist
import org.junit.Test;
^
Case_CreateOPCO.java:10: error: package UserDefine_methods does not exist
import UserDefine_methods.method_CreateOPCO;
^
Case_CreateOPCO.java:12: error: package Common.util does not exist
import Common.util.commonUtility;
^
Case_CreateOPCO.java:14: error: cannot find symbol
public class Case_CreateOPCO extends commonUtility{
^
symbol: class commonUtility
Case_CreateOPCO.java:16: error: cannot find symbol
public void BeforeTest() throws IOException, InterruptedException, Class
NotFoundException, BiffException, SQLException

^
symbol: class BiffException
location: class Case_CreateOPCO
Case_CreateOPCO.java:24: error: cannot find symbol
public void CreateOperatingCompanyTest() throws ClassNotFoundException,
BiffException, InterruptedException, SQLException, IOException

^
symbol: class BiffException
location: class Case_CreateOPCO
Case_CreateOPCO.java:15: error: cannot find symbol
@Before
^
symbol: class Before
location: class Case_CreateOPCO
Case_CreateOPCO.java:23: error: cannot find symbol
@Test
^
symbol: class Test
location: class Case_CreateOPCO
Case_CreateOPCO.java:29: error: cannot find symbol
@After
^
symbol: class After
location: class Case_CreateOPCO
Case_CreateOPCO.java:18: error: cannot find symbol
OPCO_setUp();
^
symbol: method OPCO_setUp()
location: class Case_CreateOPCO
Case_CreateOPCO.java:19: error: cannot find symbol
commonUtility.credential_OPCO();
^
symbol: variable commonUtility
location: class Case_CreateOPCO
Case_CreateOPCO.java:20: error: cannot find symbol
commonUtility.hovertoOPCO();
^
symbol: variable commonUtility
location: class Case_CreateOPCO
Case_CreateOPCO.java:26: error: cannot find symbol
method_CreateOPCO.OPCO();
^
symbol: variable method_CreateOPCO
location: class Case_CreateOPCO
Case_CreateOPCO.java:32: error: cannot find symbol
Quit();
^
symbol: method Quit()
location: class Case_CreateOPCO
17 errors

E:\Workspace\OKI\src\TestCases>java Case_CreateOPCO
Error: Could not find or load main class Case_CreateOPCO

E:\Workspace\OKI\src\TestCases>pause
Press any key to continue . . .

Reply

seetaram October 25, 2015 at 5:23 am

This is due to the Jar files not being in classpath. Remember when the libraries are referred by the Java program during the compilation, it will check for them. If does not exist then these errors will come

Reply

seetaram August 20, 2013 at 9:23 am

In Eclipse, add to buildpath

Reply

Leave a Comment

Previous post:

Next post:

Do you want to get updates on the recent articles written? Please subscribe to RSS feed or Email