How to run TestNG suite from command line - selenium

I would like to run TestNG Suite from command line on Linux. I'm using eclipse to run test, but I have problem with command line. I know that I need to have testng.jar and I have it in /home/karcio/dev/testng-6.4.jar, location my suite xml is /home/karcio/git/java-test-automation/Automation/test-output/Default suite/TestSuite.xml . Commands what I tried,
set classpath /home/karcio/dev/testng-6.4.jar
cd /location to my suite xml file: java org.testing.TestNG TestSuite.xml
This is error what I see:
Exception in thread "main" java.lang.NoClassDefFoundError: org/testing/TestNG
Caused by: java.lang.ClassNotFoundException: org.testing.TestNG
I'm new in those path and classpath, I'm little bit confusing :(
Thank you
Little update,
I think I did all good, now when I put to terminal: java org.testng.TestNG Test.xml
I've got this error:
Exception in thread "main" org.testng.TestNGException: No sourcedir
was specified at org.testng.TestNG.checkConditions(TestNG.java:1170)
at org.testng.TestNG.privateMain(TestNG.java:1010) at
org.testng.TestNG.main(TestNG.java:997)
all path are exported, so maybe this is wrong version of testng.jar, tried with versions 5.5, 6.4, 6.5, 6.6, 6.7 but I think only version 5.5 is working,

There is a typo in the class package
org.testing.TestNG
should be
org.testng.TestNG
(There no i in the .testng. part)
http://testng.org/javadoc/org/testng/TestNG.html

Related

JDeveloper 12c | IntegratedWebLogicServer | Error while building the default domain

I'm trying to run IntegratedWebLogicServer using JDeveloper Version 12.2.1.4.0, and I have the following message:
ERROR: An error occurred while building the default domain.
And the log shows:
BuildDefaultDomain1.py 2020-02-10 11:53:05
cmd.exe /c ""C:\Oracle\Middleware\Oracle_Home\oracle_common\common\bin\wlst.cmd" "C:\Users\nauana.nonato\AppData\Roaming\JDeveloper\system12.2.1.4.42.190911.2248\o.j2ee.adrs\BuildDefaultDomain1.py""
Cannot run program "cmd.exe" (in directory "C:\Oracle\Middleware\Oracle_Home\oracle_common\common\bin"): Malformed argument has embedded quote: "C:\Oracle\Middleware\Oracle_Home\oracle_common\common\bin\wlst.cmd" "C:\Users\nauana.nonato\AppData\Roaming\JDeveloper\system12.2.1.4.42.190911.2248\o.j2ee.adrs\BuildDefaultDomain1.py"
java.io.IOException: Cannot run program "cmd.exe" (in directory "C:\Oracle\Middleware\Oracle_Home\oracle_common\common\bin"): Malformed argument has embedded quote: "C:\Oracle\Middleware\Oracle_Home\oracle_common\common\bin\wlst.cmd" "C:\Users\nauana.nonato\AppData\Roaming\JDeveloper\system12.2.1.4.42.190911.2248\o.j2ee.adrs\BuildDefaultDomain1.py"
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at oracle.jdevimpl.adrs.weblogic.wlst.ScriptRunnerImpl.runScript(ScriptRunnerImpl.java:106)
at oracle.jdevimpl.adrs.weblogic.builder.DomainScriptRunnerImpl.runScript(DomainScriptRunnerImpl.java:146)
at oracle.jdevimpl.adrs.weblogic.builder.DefaultDomainBuilder.createDomain(DefaultDomainBuilder.java:606)
at oracle.jdevimpl.adrs.weblogic.builder.DefaultDomainBuilder.build(DefaultDomainBuilder.java:274)
at oracle.jdevimpl.adrs.weblogic.builder.DefaultDomainBuilder$1.run(DefaultDomainBuilder.java:225)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
Caused by: java.lang.IllegalArgumentException: Malformed argument has embedded quote: "C:\Oracle\Middleware\Oracle_Home\oracle_common\common\bin\wlst.cmd" "C:\Users\nauana.nonato\AppData\Roaming\JDeveloper\system12.2.1.4.42.190911.2248\o.j2ee.adrs\BuildDefaultDomain1.py"
at java.lang.ProcessImpl.needsEscaping(ProcessImpl.java:279)
at java.lang.ProcessImpl.createCommandLine(ProcessImpl.java:202)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:436)
at java.lang.ProcessImpl.start(ProcessImpl.java:140)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 9 more
What should I do?
Follow the following steps to fix this issues in 12.2.1.4
Go to Oracle_Home\jdeveloper\ide\bin folder.
Edit ide.conf file.
Under # Other OSGi configuration options for locating bundles and boot delegation section (or any other section) add the following line
AddVMOption -Djdk.lang.Process.allowAmbiguousCommands=true
Restart JDeveloper.
I am having the same problem as you. I am installing Oralce SOA Quick Start 12c version 12.1
Version JDK: javac 1.8.0_251
To solve this problem. You set parameters in enviroment:
-Djdk.lang.Process.allowAmbiguousCommands=true
set JAVA_TOOL_OPTIONS=-Djdk.lang.Process.allowAmbiguousCommands=true
good luck: ManhKM

RED Robot Framework Editor - Unexpected error: NoClassDefFoundError: com/github/markusbernhardt/selenium2library/utils/WebDriverCache

Im using RED robot framework editor with Java. Though i have added the jar file that contains
'com/github/markusbernhardt/selenium2library/utils/WebDriverCache', it errors as "NoClassDefFoundError"
I use robotframework-selenium2library-java-1.4.0.8 for creating java library.
Below is the console command generated in RED editor.
Command: C:\jython2.7.0\bin\jython.exe -J-Dpython.path=C:\jython2.7.0\Lib\site-packages -J-cp .;C:\Java\JarsKCC\Misc.jar;C:\Java\JarsKCC\KCCUtils.jar;C:\Java\JarsKCC\GetElementList.jar;C:\jython2.7.0\selenium-server-standalone-3.3.1.jar;C:\jython2.7.0\robotframework-selenium2library-java-1.4.0.8 -m robot.run -P C:\jython2.7.0\Lib\site-packages\Selenium2Library --listener C:\Users\CON_RT~1\AppData\Local\Temp\RobotTempDir2533122362618779828\TestRunnerAgent.py:56178:False -s KCC_Automation.TestSuites.TestSeparateWebdriverInstance C:\Java\Workspace\KCC_Automation
Suite Executor: Robot Framework 3.0.2 (Jython 2.7.0 on java1.8.0_121)
Error received while execution is,
[ ERROR ] Unexpected error: NoClassDefFoundError:
com/github/markusbernhardt/selenium2library/utils/WebDriverCache
java.lang.NoClassDefFoundError:
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetPublicMethods(Class.java:2902)
at java.lang.Class.getMethods(Class.java:1615)
at robot.utils.importer$py.import_$32(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:274)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.utils.importer$py._import_class_or_module$5(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:77)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.utils.importer$py.import_class_or_module$4(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py:74)
at robot.utils.importer$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\importer.py)
at robot.model.visitor$py.visit_suite$2(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py:88)
at robot.model.visitor$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py)
at robot.model.testsuite$py.visit$19(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py:161)
at robot.model.testsuite$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py)
at robot.model.itemlist$py.visit$11(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py:75)
at robot.model.itemlist$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py)
at robot.model.visitor$py.visit_suite$2(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py:88)
at robot.model.visitor$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py)
at robot.model.testsuite$py.visit$19(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py:161)
at robot.model.testsuite$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py)
at robot.model.itemlist$py.visit$11(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py:75)
at robot.model.itemlist$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\itemlist.py)
at robot.model.visitor$py.visit_suite$2(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py:88)
at robot.model.visitor$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\visitor.py)
at robot.model.testsuite$py.visit$19(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py:161)
at robot.model.testsuite$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\model\testsuite.py)
at robot.utils.application$py._execute$10(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py:94)
at robot.utils.application$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py)
at robot.utils.application$py.execute_cli$5(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py:49)
at robot.utils.application$py.call_function(C:\jython2.7.0\Lib\site-packages\robot\utils\application.py)
at runpy$py._run_code$9(C:\jython2.7.0\Lib\runpy.py:73)
at runpy$py.call_function(C:\jython2.7.0\Lib\runpy.py)
at runpy$py._run_module_as_main$14(C:\jython2.7.0\Lib\runpy.py:161)
at runpy$py.call_function(C:\jython2.7.0\Lib\runpy.py)
Caused by: java.lang.ClassNotFoundException:
com.github.markusbernhardt.selenium2library.utils.WebDriverCache
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 190 more
Java code I used from this blog
Note: I also verified with the dependency jar file 'robotframework-selenium2library-java-1.4.0.8-jar-with-dependencies'. I still face the same issue.
The examples in the 'blog' / stackoverflow post had some issues, with the key one being that the name of the class was changed since the answer was written on SO. However, when I compiled the jar file and added the jar file to the class path section of the red.xml none of the errors mentioned in the question were encountered. As the referred SO question had two approaches, I tried them both.
It appears to me that you have specified the directory and not the jar file for the robotframework-selenium2library-java-1.4.0.8.
C:\jython2.7.0\bin\jython.exe
-J-Dpython.path=C:\jython2.7.0\Lib\site-packages
-J-cp .
;C:\Java\JarsKCC\Misc.jar
;C:\Java\JarsKCC\KCCUtils.jar
;C:\Java\JarsKCC\GetElementList.jar
;C:\jython2.7.0\selenium-server-standalone-3.3.1.jar
;C:\jython2.7.0\robotframework-selenium2library-java-1.4.0.8
-m robot.run
-P C:\jython2.7.0\Lib\site-packages\Selenium2Library
--listener C:\Users\CON_RT~1\AppData\ ... \TestRunnerAgent.py:56178:False
-s KCC_Automation.TestSuites.TestSeparateWebdriverInstance
C:\Java\Workspace\KCC_Automation
So my advice is to change this so that the classpath reflects the jar file:
;C:\jython2.7.0\robotframework-selenium2library-java-1.4.0.8\some-jar-name.jar

NullPointerException org.gradle.wrapper.BootstrapMainStarter.findLauncherJar(BootstrapMainStarter.java:37)

Got the following stacktrace when launching gradle 1.1, anyone know how to resolve them:
Exception in thread "main" java.lang.NullPointerException
at org.gradle.wrapper.BootstrapMainStarter.findLauncherJar(BootstrapMainStarter.java:37)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:28)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:47)
I think the automatic unzip of the dists/gradle-1.1-bin/13d7lnhcrghv2i5e54el41jpgr/gradle-1.1-bin.zip might be failing. I checked permissions and that I have access to that directory.
If I unzip manually, then I get the following error:
Exception in thread "main" java.lang.RuntimeException: Gradle distribution 'http://services.gradle.org/distributions/gradle-1.1-bin.zip' contains too many directories. Expected to find exactly 1 directory.
at org.gradle.wrapper.Install.createDist(Install.java:73)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:47)
I did a google search for gradle nullpointerexception and it mentioned the JAVA_HOME needs to be set for compiling, but I've already checked it is set correctly and been able to compile stuff with ant in that environment.
I was getting exactly same error and I changed the version of gradle that I was using. Inside my gradle-wrapper.properties, changed version 2.4 to 2.2.1 and error is gone.

(java)Could not find the main class

My code is compiled on OSX and it works fine(compiler version 1.6). But when I copy it to a remote ubuntu. I can not run it.
When I run
java TPCC.class
I got exception like this.(By the way TPCC.class is in default package)
Exception in thread "main" java.lang.NoClassDefFoundError: TPCC/class
Caused by: java.lang.ClassNotFoundException: TPCC.class
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: TPCC.class. Program will exit.
And my java version on ubuntu:
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Client VM (build 17.0-b16, mixed mode, sharing)
It's also 1.6 and I think it fits the compiled binary. How can I fix this problem?
The problem is in the way you run the program. Compiled java called
ClassName.java
will be ClassName.class. You should run it like
"java ClassName"
. You shouldn't run it as
"java ClassName.class"
What happens here is this. When you run it as java ClassName.class, JVM try to look for ClassName called "class" in the package called "ClassName" that does not exist. So it will throw NoClassDefFoundError.
This is an invocation problem as the error shows: java should be used and not the filename of the class.
The error message tries to say you this by stating that "TPCC/class" is not found.
(sorry for first adding comment, used the wrong field)
Specify the classpath when invoking java:
java -cp <path-to-jar> TPCC

BuildException when executing Ant task

I have installed Apache Ant and set the correctly the Path, CLASS_PATH and ANT_PATH variables. When I run a jar task in a command line within my project folder where the build.xml file is, I get the following error:
BUILD FAILED
C:\Documents and Settings\TonyS\My Documents\My Workspace\code\build.xml: 32:
The following error occurred while executing this line:
jar:file:/C:/Documents%20and%20Settings/TonyS/My%20Documents/Ant/apache-ant-1.8.1/lib/ant.jar!org/apache/tools/ant/antlib.xml:37: Could not create task or type: componentdef.
Ant could not find the task or a class this task relies upon.
I had this error and found it was caused by having an older version of ant.jar in the classpath.
One possibility is you may have another version of ant installed on your system and your PATH pointing to it.
Check what is ANT_HOME set to.
Run ant -version and see if it shows up 1.8.1
Add the following config in ~/.bashrc
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
Don't forget source ~/.bashrc
Hope useful for you!
you have duplicate ant in your environment.
My case was:
I am using 1.9.7 ant, but ant -version gave me 1.7.1
I installed weblogic and it has 1.7.1 ant, after rename MW_HOME, the issue was gone.
I found this while I was using 1.7.1 to test junit. it shows a warning.
junit:
[junit] WARNING: multiple versions of ant detected in path for junit
[junit] jar:file:/D:/wls12120/oracle_common/modules/org.apache.ant_1.7.1/lib/ant.jar!/org/apache/tools/ant/
Project.class
[junit] and jar:file:/D:/apache-ant-1.7.1/lib/ant.jar!/org/apache/tools/ant/Project.class
[junit] Running HelloWorldTest