I am running appium test using testng want to pass app path to desired capabilities as parameter to testng.xml file how can i do this from command line with maven ?
xml file via command line allows user to run multiple testng xml files simultaneously. Before running a testng. xml suite through the command prompt, we need to compile our project code. We can find the compiled code by eclipse under a folder named “bin” inside the corresponding java project.
Lets say you have a suite xml file which looks like below
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="sample_suite" verbose="1" parallel="false" thread-count="2">
<test name="sample_test">
<parameter name="name" value="Krishnan"/>
<classes>
<class name="ParameterisedSampleTestClass" />
</classes>
</test>
</suite>
And you would like to change the value of the parameter name
to a different value other than Krishnan
(which is what is defined in the suite xml file)
You basically do this by passing the JVM argument -Dname=John
.
TestNG by default supports changing parameter values and accepts values at run via JVM arguments.
You just need to use the same name as your parameter name, for the JVM argument.
You can find more details in my blog post here
You can achieve this by providing JVM argument as Krishnan mention in post bellow and nice blog in link:
mvn -Dbrowser="chrome" test
and gather them in your code (eg. java) via
String broswser = System.getProperty(browser);
and then turn into desired capabilities afterwards:
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapability.setBrowserName(browser);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With