简体   繁体   中英

Unable to run Selenium tests (java) from the command line

I am using Selenium to do tests on some html. I was using java under Eclipse and run test by Junit. And everything was fine. But I got problems when I started use command line (javac/java at Dos prompt) to compile/run the test. For this java project, I have a bunch of classes, each one represents one test while each each class sits in its own java file. And All these files are under one package/folder called "testSuite". Each test file will import a bunch of jar files. And they also import Global class from another The problems, the compile was ok. but I make it run. I compiled global.java first then compiled PolicyFilter.java and then try to run the class, below is what I got:

Exception in thread "main" java.lang.NoClassDefFoundError: \testsuite\PolicyFilter (wrong name: testSuite/PolicyFilter)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)

Please use java -cp requiredClassfiles/folders/jars classToExecute .

I hope you have Selenium RC Jar available and started it using command java -jar selenium-server-standalone-<version-number>.jar .

Make sure that you put the annotation @Test on the test, clean the folder target in project folder and then restart the eclipse. Hope it works :))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM