Run tests through command line + java + TestNG

12,152 views
Skip to first unread message

Elangovan Ganesh

unread,
Jan 27, 2012, 1:08:53 AM1/27/12
to Selenium Users
Hi All,

I want to schedule the tests in windows task scheduler. So i want to
invoke tests through the command line to build the batch files.

I explored on the TestNG documentation. It says like

Assuming that you have TestNG in your class path, the simplest way to
invoke TestNG is as follows:
java org.testng.TestNG testng1.xml [testng2.xml testng3.xml ...]

I am not clear on this.. org.testng.TestNG is testNG jar file?

i ran the command, java -jar testNG.jar org.testng.TestNG
testsuite.xml, But i am getting TestNGException: org.testng.TestNG not
found.

Please suggest me how to invoke suites from the command line?



Thanks,
Elangovan G

Krishnan Mahadevan

unread,
Jan 27, 2012, 2:08:02 AM1/27/12
to seleniu...@googlegroups.com
Assuming that the current directory has testng.jar you would invoke the main class of TestNG using
java org.testng.TestNG suite.xml


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



--
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.


Elangovan Ganesan

unread,
Jan 27, 2012, 6:03:01 AM1/27/12
to seleniu...@googlegroups.com
ok krishnan,

i have testng.jar in C:\users\ . But it gives the following error.

C:\Users>java org.testng.TestNG homepage.xml
Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNG
Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.testng.TestNG. Program will exit.

jerald

unread,
Jan 27, 2012, 6:16:27 AM1/27/12
to seleniu...@googlegroups.com
This is a classpath problem. set the curent directory in class path before executing the test.

C:\Users>set classpath=%classpath%;.

and then run the test as told by him.
Thanks and Kind Regards
jerald

Krishnan Mahadevan

unread,
Jan 27, 2012, 6:27:00 AM1/27/12
to seleniu...@googlegroups.com
Elangovan,
This should add more clarity to your question : http://www.roseindia.net/java/java-classpath.shtml

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


Elangovan Ganesan

unread,
Jan 27, 2012, 7:09:16 AM1/27/12
to seleniu...@googlegroups.com

Hi Krish & Jerald,

I explored in the link, classpath means as same as adding external jar file through configure build path in eclipse?.

my project name is matrix... which resides in the path D:\Subversion\QASCRIPTS\trunk\Matrix and testtng.jar is in its classpath

so i set the classpath as follows ,

C:\Users\BPA PV2000>set classpath = D:\Subversion\QASCRIPTS\trunk\Matrix\testng-
5.14.1.jar

C:\Users\BPA PV2000>java org.testng.TestNG D:\Subversion\QASCRIPTS\trunk\Matrix\
xml\homepage.xml

Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNG
Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
        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)

Could not find the main class: org.testng.TestNG.  Program will exit.

Am not clear on this.

Please can you explain me in detail.




On Fri, Jan 27, 2012 at 4:46 PM, jerald <paulj...@gmail.com> wrote:

Elangovan Ganesan

unread,
Jan 27, 2012, 7:22:33 AM1/27/12
to seleniu...@googlegroups.com
Hi,

Here Do i need to compile all the java files i have?

before run the testng.xml file?


Thanks,
Elangovan G.

jerald

unread,
Jan 27, 2012, 8:06:30 AM1/27/12
to seleniu...@googlegroups.com
Try this and let me know

C:\Users\BPA PV2000>java -classpath D:\Subversion\QASCRIPTS\trunk\Matrix\testng-5.14.1.jar org.testng.TestNG D:\Subversion\QASCRIPTS\trunk\Matrix\xml\homepage.xml


Thanks and Kind Regards
jerald



Elangovan Ganesan

unread,
Jan 27, 2012, 8:41:28 AM1/27/12
to seleniu...@googlegroups.com
Hi,

It gives error as follows,

C:\>java -classpath D:\Subversion\QASCRIPTS\trunk\Matrix\testng-5.14.1.jar org.t


estng.TestNG D:\Subversion\QASCRIPTS\trunk\Matrix\xml\homepage.xml

[ClassHelper] Could not instantiate com.matrix.qa.test.TestHome: com.matrix.qa.t
est.TestHome
[ClassHelper] Could not instantiate com.matrix.qa.test.TestHome: com.matrix.qa.t
est.TestHome
org.testng.TestNGException:
Cannot find class in classpath: com.matrix.qa.test.TestHome
at org.testng.xml.XmlClass.getSupportClass(XmlClass.java:59)
at org.testng.internal.ClassInfoMap.<init>(ClassInfoMap.java:19)
at org.testng.TestRunner.initMethods(TestRunner.java:395)
at org.testng.TestRunner.init(TestRunner.java:234)
at org.testng.TestRunner.init(TestRunner.java:204)
at org.testng.TestRunner.<init>(TestRunner.java:146)
at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRu
nner.java:499)
at org.testng.SuiteRunner.init(SuiteRunner.java:140)

com.matrix.qa.test.TestHome is our test class.

Before i run this do i need to compile all the java classes?

Thanks,
Elangovan G.

Mike Riley

unread,
Jan 27, 2012, 6:37:35 PM1/27/12
to Selenium Users
I am not using CLASSPATH myself, because it is handled by the manifest
file in my jar, but I recall reading (when I was looking into
CLASSPATH) that ending with /* for a directory path would work. You
are putting a specific jar file in CLASSPATH, when really you want the
directory.

Try this:

java -classpath D:\Subversion\QASCRIPTS\trunk\Matrix/*
org.testng.TestNG D:\Subversion\QASCRIPTS\trunk\Matrix\xml
\homepage.xml

If that doesn't work, try it without the /* at the end.

When I was researching CLASSPATH I found that if you use a jar file it
is ignored, so I simply place my library jars in a directory listed in
my manifest file and it works fine. It does mean that I end up
renaming the libs directory for Selenium to lib, but that does not
bother Selenium at all.

I am curious why you are using an older TestNG than what comes with
Selenium.

Mike

On Jan 27, 5:41 am, Elangovan Ganesan <golagan...@gmail.com> wrote:
> Hi,
>
> It gives error as follows,
>
> C:\>java -classpath D:\Subversion\QASCRIPTS\trunk\Matrix\testng-5.14.1.jar org.t
> estng.TestNG D:\Subversion\QASCRIPTS\trunk\Matrix\xml\homepage.xml
> [ClassHelper] Could not instantiate com.matrix.qa.test.TestHome: com.matrix.qa.t
> est.TestHome
> [ClassHelper] Could not instantiate com.matrix.qa.test.TestHome: com.matrix.qa.t
> est.TestHome
> org.testng.TestNGException:
> Cannot find class in classpath: com.matrix.qa.test.TestHome
>         at org.testng.xml.XmlClass.getSupportClass(XmlClass.java:59)
>         at org.testng.internal.ClassInfoMap.<init>(ClassInfoMap.java:19)
>         at org.testng.TestRunner.initMethods(TestRunner.java:395)
>         at org.testng.TestRunner.init(TestRunner.java:234)
>         at org.testng.TestRunner.init(TestRunner.java:204)
>         at org.testng.TestRunner.<init>(TestRunner.java:146)
>         at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRu
> nner.java:499)
>         at org.testng.SuiteRunner.init(SuiteRunner.java:140)
>
> com.matrix.qa.test.TestHome is our test class.
>
> Before i run this do i need to compile all the java classes?
>
> Thanks,
> Elangovan G.
>
> On 1/27/12, jerald <pauljer...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Try this and let me know
>
> > C:\Users\BPA PV2000>java -classpath
> > D:\Subversion\QASCRIPTS\trunk\Matrix\testng-5.14.1.jar org.testng.TestNG
> > D:\Subversion\QASCRIPTS\trunk\Matrix\xml\homepage.xml
>
> > Thanks and Kind Regards
> > jerald
>
> > On 27 January 2012 17:52, Elangovan Ganesan <golagan...@gmail.com> wrote:
>
> >> Hi,
>
> >> Here Do i need to compile all the java files i have?
>
> >> before run the testng.xml file?
>
> >> Thanks,
> >> Elangovan G.
>
> >> > On Fri, Jan 27, 2012 at 4:46 PM, jerald <pauljer...@gmail.com> wrote:
>
> >> >> This is a classpath problem. set the curent directory in class path
> >> >> before
> >> >> executing the test.
>
> >> >> C:\Users>set classpath=%classpath%;.
>
> >> >> and then run the test as told by him.
> >> >> Thanks and Kind Regards
> >> >> jerald
>
> >> >> On 27 January 2012 16:33, Elangovan Ganesan <golagan...@gmail.com>
> >> wrote:
>
> >> >>> ok krishnan,
>
> >> >>> i have testng.jar in C:\users\ . But it gives the following error.
>
> >> >>> C:\Users>java org.testng.TestNG homepage.xml
> >> >>> Exception in thread "main" java.lang.NoClassDefFoundError:
> >> >>> org/testng/TestNG
> >> >>> Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
> >> >>>        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
> >> >>>        at java.security.AccessController.doPrivileged(Native Method)
> >> >>>        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> >> >>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> >> >>>        at
> >> >>> sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> >> >>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
> >> >>> Could not find the main class: org.testng.TestNG.  Program will exit.
>
> >> >>> On 1/27/12, Krishnan Mahadevan <krishnan.mahadevan1...@gmail.com>
> >> wrote:
> >> >>> > Assuming that the current directory has testng.jar you would invoke
> >> >>> > the
> >> >>> > main class of TestNG using
> >> >>> > java org.testng.TestNG suite.xml
>
> >> >>> > Thanks & Regards
> >> >>> > Krishnan Mahadevan
>
> >> >>> > "All the desirable things in life are either illegal, expensive,
> >> >>> fattening
> >> >>> > or in love with someone else!"
>
> >> >>> > On Fri, Jan 27, 2012 at 11:38 AM, Elangovan Ganesh
> >> >>> > <golagan...@gmail.com>wrote:

Elangovan Ganesan

unread,
Jan 28, 2012, 4:13:26 PM1/28/12
to seleniu...@googlegroups.com
Hi Mike,

This too not working, I have the testng.jar in the path


D:\Subversion\QASCRIPTS\trunk\Matrix

java -classpath D:\Subversion\QASCRIPTS\trunk\Matrix\* org.t


estng.TestNG D:\Subversion\QASCRIPTS\trunk\Matrix\xml\homepage.xml

Exception in thread "main" java.lang.NoClassDefFoundError: D:\Subversion\QASCRIP
TS\trunk\Matrix\/project
Caused by: java.lang.ClassNotFoundException: D:\Subversion\QASCRIPTS\trunk\Matri
x\.project


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)

Could not find the main class: D:\Subversion\QASCRIPTS\trunk\Matrix\.project. P
rogram will exit.

C:\Users\BPA PV2000>java -classpath D:\Subversion\QASCRIPTS\trunk\Matrix org.tes


tng.TestNG D:\Subversion\QASCRIPTS\trunk\Matrix\xml\homepage.xml
Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNG
Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
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)
Could not find the main class: org.testng.TestNG. Program will exit.

I am not getting this


"When I was researching CLASSPATH I found that if you use a jar file it
is ignored, so I simply place my library jars in a directory listed in
my manifest file and it works fine. It does mean that I end up
renaming the libs directory for Selenium to lib, but that does not
bother Selenium at all."

you mean, telling to list the jar files in the MANIFEST.MF file of the
jar testng.jar. I am not able to edit this MANIFEST.MF file.

I really want this soon... I needed to schedule my testsuites. I can
do this if i run tests from command line. Please let me know the full
procedure.

Before run the test Don't i need to compile the java classes present
in testsuite.xml?

and also what it mean, older TestNG means," I am curious why you are


using an older TestNG than what comes with Selenium."

Thanks,
Elangovan G.

Lutfi Dughman

unread,
Jan 28, 2012, 4:25:03 PM1/28/12
to seleniu...@googlegroups.com
ok, i havent read the whole thread but i would like to suggest something:

I have downloaded the TestNG jar file, its called  testng-6.3.1.jar

now i have never used testng, but here is what i would do if i were about to use it

jar -classpath="c:\dir\where\you\have\testng\jarfile\testng-6.3.1.jar"  org.testng.TestNG

replace "c:\dir\where\you\have\testng\jarfile\" with the actual directory that contains testng-6.3.1.jar jarfile

ofcourse im assuming the static main method exists in  org.testng.TestNG.


try this and let us know what happens

Lutfi Dughman

unread,
Jan 28, 2012, 9:27:56 PM1/28/12
to seleniu...@googlegroups.com
there is no = after class path only a space

Elangovan Ganesan

unread,
Jan 29, 2012, 6:44:34 AM1/29/12
to seleniu...@googlegroups.com
Hi,

I am getting this only.

C:\Users\BPA PV2000>java -classpath "D:\Subversion\QASCRIPTS\trunk\Matrix\testng
-5.14.1.jar" org.testng.TestNG D:\Subversion\QASCRIPTS\trunk\Matrix\xml\homepage
.xml
[ClassHelper] Could not instantiate com.matrix.qa.test.TestHome: com.matrix.qa.t
est.TestHome
[ClassHelper] Could not instantiate com.matrix.qa.test.TestHome: com.matrix.qa.t
est.TestHome
org.testng.TestNGException:
Cannot find class in classpath: com.matrix.qa.test.TestHome
        at org.testng.xml.XmlClass.getSupportClass(XmlClass.java:59)
        at org.testng.internal.ClassInfoMap.<init>(ClassInfoMap.java:19)
        at org.testng.TestRunner.initMethods(TestRunner.java:395)
        at org.testng.TestRunner.init(TestRunner.java:234)
        at org.testng.TestRunner.init(TestRunner.java:204)
        at org.testng.TestRunner.<init>(TestRunner.java:146)
        at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRu
nner.java:499)
        at org.testng.SuiteRunner.init(SuiteRunner.java:140)
        at org.testng.SuiteRunner.<init>(SuiteRunner.java:104)
        at org.testng.TestNG.createSuiteRunner(TestNG.java:1120)
        at org.testng.TestNG.createSuiteRunners(TestNG.java:1106)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:952)
        at org.testng.TestNG.run(TestNG.java:896)
        at org.testng.TestNG.privateMain(TestNG.java:1193)
        at org.testng.TestNG.main(TestNG.java:1153)

Lutfi Dughman

unread,
Jan 29, 2012, 4:10:35 PM1/29/12
to seleniu...@googlegroups.com
there are dependencies in ur test that are not included in the class path.

i have tried to lookup the web for "com.matrix.qa.test.TestHome" but it cand find any reference, so its a custom class that you have built.

ALL the classes and jar files that your test uses MUST be included in the classpath declaration, otherwise you will keep getting errors like the one above

Krishnan Mahadevan

unread,
Jan 29, 2012, 11:18:29 PM1/29/12
to seleniu...@googlegroups.com
Elangovan,
Perhaps you can take a look at this post and see if that helps



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



Elangovan Ganesan

unread,
Jan 30, 2012, 5:48:22 AM1/30/12
to seleniu...@googlegroups.com
Hi,

It is really make me dump.

I have added all the jar files and all the classes by setting the classpath

But system is not able to find 'org.test.TestNG'

d:\Subversion\QASCRIPTS\trunk\Matrix>java org.testng.TestNG D:\Subversion\QASCRI
PTS\trunk\Matrix\xml\homepage.xml
Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNG
Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: org.testng.TestNG.  Program will exit.

I am planning to go to Maven. The documentation provided is not that much clear to me.

Please help me out to use Maven to schedule the test.


Thanks,
Elangovan G.

Mark Collin

unread,
Jan 30, 2012, 6:03:21 AM1/30/12
to seleniu...@googlegroups.com

This is a mavenised Selenium test framework, it may provide some pointers:

 

https://github.com/Ardesco/Ebselen


-- This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error please notify postm...@ardescosolutions.com

Elangovan Ganesan

unread,
Jan 30, 2012, 7:56:40 AM1/30/12
to seleniu...@googlegroups.com
Hi,

From the scratch am using TestNG and Eclipse for my project,
The mavenised selenium framework seems to use @seleniumTest at all.

Now I want to schedule the tests. 

Please suggest me to which one choose either Ant / Maven? Which one is easy and best?

and i need some sample projects done using ant/maven.


Thanks,
Elangovan G.

Krishnan Mahadevan

unread,
Jan 30, 2012, 8:04:00 AM1/30/12
to seleniu...@googlegroups.com
Neither Ant nor Maven AFAIK can schedule Tests. Both of them are build tools.
For scheduling you would need to use either the task scheduler available with the OS or resort to using continuous integration tools such as Hudson/Jenkins.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


Elangovan Ganesan

unread,
Jan 30, 2012, 8:11:43 AM1/30/12
to seleniu...@googlegroups.com
Hi Krish,

Ant Don't give .exe of testsuite?

We can schedule this .exe file in windows task manager right?

How do we run the ant build file? Through command line or?


Thanks,
Elangovan G

Mark Collin

unread,
Jan 30, 2012, 8:17:20 AM1/30/12
to seleniu...@googlegroups.com

Not sure what you mean with the first two lines…

 

The mavenised framework I gave you a link to uses JUnit instead of TestNG, but as an example it should show you how things are done, TestNG and JUnit are pretty interchangeable.

 

Maven is excellent for dependency management and if you don’t do anything complex during your build process is usually fine.  Ant has a lot more granularity and is easier to use if you want to do complex stuff during your build IMHO.  You’ll probably find a million different views on the net ranging from Maven = Hell to Ant = Hell. The best thing to do is try them and see which you prefer personally.  You can use both of them together if you want to (there are varying ways to mix and match them).

Krishnan Mahadevan

unread,
Jan 30, 2012, 8:24:55 AM1/30/12
to seleniu...@googlegroups.com
I second all that Mark already highlighted over here.
I dont think I have anything extra to add on top of what he already has suggested. The best way to figure out what suites you is to play around with them. I felt pampered by maven, so never even bothered to explore ant.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


Mike Riley

unread,
Jan 30, 2012, 12:35:19 PM1/30/12
to Selenium Users
Answers to your two questions below:

On Jan 28, 1:13 pm, Elangovan Ganesan <golagan...@gmail.com> wrote:
> you mean, telling to list the jar files in the MANIFEST.MF file of the
> jar testng.jar. I am not able to edit this MANIFEST.MF file.
>
> I really want this soon... I needed to schedule my testsuites. I can
> do this if i run tests from command line. Please let me know the full
> procedure.
>
> Before run the test Don't i need to compile the java classes present
> in testsuite.xml?

I use Netbeans, not Eclipse, but I also did not have control over the
contents of the MANIFEST.MF file. There probably was a way to make
changes by editing the ANT script that built everything, but if I
couldn't handle it using commands within the IDE I didn't want to go
there.

However, it does create a lib directory under where it builds the jar
file, into which it copies all dependent libraries the project uses.
The MANIFEST file is set up to look for any libraries it needs in ./
lib (relative to where the jar file is run from). So I simply rename
the libs directory that is where the dependent libraries for Selenium
are put and add my own libraries into it. Everything just works
then. Apparently Selenium can use either libs or lib to contain the
directories. As a backup I do configure CLASSPATH to define both the
absolute path and a relative path to the lib directory I create, just
in case something needs it defined that way.

> and also what it mean, older TestNG means," I am curious why you are
> using an older TestNG than what comes with Selenium."

What I meant by this is that Selenium comes with a copy of TestNG
6.0.1 built into it. If you are using Selenium you don't need to
provide any TestNG library, at least not an older one. The file is
called testng-6.0.1-nobsh-noguice.jar in the libs directory for
Selenium. If you wanted to use a newer version of TestNG you could
replace that with the newer version, but I can't imagine why you would
want to use the older 5.14.1 version when a newer one is already
there.

As for how to start the tests, many people here use either ANT or
Maven to start them, I believe. I know that you can start a test
within the IDE, but that is generally for testing the code you have
written for a standalone application, where what is really wanted for
Selenium is to have the test code be part of the application.

So I actually create the testng XML info within my code as part of my
main() method. I ended up creating some methods that set up the
report directory, start a new test suite, and add test case classes to
the current test suite, but it can all be done inline. Take a look at
this web site for how to set up your tests using Java code. Note that
now actual XML file gets written out, except as part of the report.
Instead it is kept all in memory until it is time to write out the
report:

http://testng.org/doc/documentation-main.html#running-testng-programmatically

Mike

skd

unread,
Jan 30, 2012, 12:59:04 PM1/30/12
to seleniu...@googlegroups.com
Yes, you need to compile all the java classes that make up your tests.  The directory containing those compiled class files also needs to be on the classpath.  So, assuming the file TestHome.class is in D:\Subversion\QASCRIPTS\trunk\Matrix\testclasses\com\matrix\qa\test, your command-line would look like this:

C:\>java -classpath "D:\Subversion\QASCRIPTS\trunk\Matrix\testng-5.14.1.jar;D:\Subversion\QASCRIPTS\trunk\Matrix\testclasses" org.testng.TestNG D:\Subversion\QASCRIPTS\trunk\Matrix\xml\homepage.xml


MOHAMADOU

unread,
Jan 31, 2012, 5:55:35 AM1/31/12
to Selenium Users
hello i cand send email with one attach but i would like to send it
with three attach here my code java

selenium.click("//span[text()='Joindre un fichier']");
Thread.sleep(5000);
selenium.type("css=.LIODqc", "/usr/share/example-content/
Trigonométrie.xls");
Thread.sleep(5000);
selenium.click("//span[text()='Joindre un autre fichier']");
selenium.type("css=.LIODqc", "/usr/share/example-content/Échéancier-
paiement.ods"); selenium.click("//span[text()='Joindre un autre
fichier']");
; now only one file is send beacause it use only css=.LIODqc don't
have another solution??

thanx in adavnce

On Jan 30, 6:59 pm, skd <skd...@gmail.com> wrote:
> Yes, you need to compile all the java classes that make up your tests.  The
> directory containing those compiled class files also needs to be on the
> classpath.  So, assuming the file TestHome.class is in
> D:\Subversion\QASCRIPTS\trunk\Matrix\testclasses\com\matrix\qa\test, your
> command-line would look like this:
>
> C:\>java -classpath
> "D:\Subversion\QASCRIPTS\trunk\Matrix\testng-5.14.1.jar;D:\Subversion\QASCR IPTS\trunk\Matrix\testclasses"

Elangovan Ganesan

unread,
Feb 3, 2012, 4:24:00 AM2/3/12
to seleniu...@googlegroups.com
Hi friends,

Finally i shceduled the batch file in to Task schedular. Batch file has commands to invoke the ant build file. Now testsuite is running for every 30minutes. It is done in local machine only. It has to done in VM in future.

Thanks a lot to everyone :D


Regards,

Kiruthika

unread,
Jun 20, 2012, 6:22:30 PM6/20/12
to seleniu...@googlegroups.com
Hi Ganesh,
Can you please give more details on this.
Did you use Maven+TestNG? how did you run the selenium tests?

I am trying to do something similar. I have my selenium tests in Java+TestNG running in a linux headless box.
Selenium starts and navigates to the '-htmlSuite' test file mentioned in the parameter but does not execute the tests since they are in testng.xml (in turn the java files)

Any help is appreciated.

Thanks,


On Friday, February 3, 2012 4:24:00 AM UTC-5, Elangovan Ganesh wrote:
Hi friends,

Finally i shceduled the batch file in to Task schedular. Batch file has commands to invoke the ant build file. Now testsuite is running for every 30minutes. It is done in local machine only. It has to done in VM in future.

Thanks a lot to everyone :D


Regards,
On Mon, Jan 30, 2012 at 6:54 PM, Krishnan Mahadevan <krishnan.mahadevan1978@gmail.com> wrote:
I second all that Mark already highlighted over here.
I dont think I have anything extra to add on top of what he already has suggested. The best way to figure out what suites you is to play around with them. I felt pampered by maven, so never even bothered to explore ant.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


On Mon, Jan 30, 2012 at 6:47 PM, Mark Collin <ma...@ardescosolutions.com> wrote:

Not sure what you mean with the first two lines…

 

The mavenised framework I gave you a link to uses JUnit instead of TestNG, but as an example it should show you how things are done, TestNG and JUnit are pretty interchangeable.

 

Maven is excellent for dependency management and if you don’t do anything complex during your build process is usually fine.  Ant has a lot more granularity and is easier to use if you want to do complex stuff during your build IMHO.  You’ll probably find a million different views on the net ranging from Maven = Hell to Ant = Hell. The best thing to do is try them and see which you prefer personally.  You can use both of them together if you want to (there are varying ways to mix and match them).

 

From: selenium-users@googlegroups.com [mailto:selenium-users@googlegroups.com] On Behalf Of Elangovan Ganesan
Sent: 30 January 2012 12:57


>> >> >>> >> To unsubscribe from this group, send email to


>> >> >>> >> 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


>> >> .
>> >> >>> > To unsubscribe from this group, send email to


>> >> >>> > 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


>> >> >>> To unsubscribe from this group, send email to


>> >> >>> 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


>> >> >> To unsubscribe from this group, send email to


>> >> >> 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 selenium-users@googlegroups.com.


>> >> To unsubscribe from this group, send email to


>> >> 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 selenium-users@googlegroups.com.


>> > To unsubscribe from this group, send email to


>> > 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 selenium-users@googlegroups.com.


> To unsubscribe from this group, send email to


> 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 selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@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 selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@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 selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@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 selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@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 selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@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 selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.


For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


-- This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error please notify postmaster@ardescosolutions.com

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.

To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@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 selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.


For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


-- This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error please notify postmaster@ardescosolutions.com

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@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 selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

Elangovan Ganesan

unread,
Jun 21, 2012, 12:36:34 AM6/21/12
to seleniu...@googlegroups.com
Hi,

I have used Ant build file to run my testng.xml file. After that i invoked ant build file from the command prompt 
like ant -f build.xml

then created the batch file with the above command.

Finally i added that batch as a task in Windows Task Scheduler(Vista)


Thanks,
Elangovan G.



To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/za5AvYRwHtcJ.

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-US.

Kiruthika

unread,
Jun 21, 2012, 11:26:30 AM6/21/12
to seleniu...@googlegroups.com
Thank you...

To post to this group, send email to selenium-users@googlegroups.com.

To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.

Datenschutz

unread,
Aug 19, 2012, 5:10:15 AM8/19/12
to seleniu...@googlegroups.com
That fixed it for me without having to use ant...  In addition tot the guide on the website I also put all webdriver files into the projects directory (which is not a good idea but it was only an experiement )
http://qtp-automate.blogspot.de/2011/10/running-selenium-testng-test-from.html

Ravi Gunasekaran

unread,
Sep 24, 2013, 12:01:39 AM9/24/13
to seleniu...@googlegroups.com
Hi Elangovan.G,

  Please try this solution to run the testNG from the Command Line it is working.

java -classpath "Path of TestNG.jar"; org.testng.TestNG "your_TestNG.xml"


If you want to run your code in standalone machine without Eclipse IDE.Create Executable .Jar file using eclipse and use below option to run the testNG from command prompt.

java -classpath"Path of TestNG.jar";"Your_classe_executable_Jar_path.jar"; . org.testng.TestNG  "your_TestNG.xml"


Regards,
G.Ravi

ayan paul

unread,
Mar 20, 2014, 5:47:08 AM3/20/14
to seleniu...@googlegroups.com
Hi,

my java class is a.java which is created in netbean using selenium library. I want to run the .java file using command line. Please let me know the commands for the same.

yarragunt...@gmail.com

unread,
Jun 18, 2016, 10:35:19 PM6/18/16
to Selenium Users
Hi Ravi/Elangovan,

Thanks for the solution.This solution is working for me in standalone..

Thanks,
Praveen
Reply all
Reply to author
Forward
0 new messages