I am testing a web client application using Java 8 Update 151 & Selenium 3.8.1. and TestNG. I have to start one test from within an already running test.
Here is my code for that:
ITestNGListener testListenerAdapter = null;
TestNG testNG = new TestNG();
testNG.addListener(testListenerAdapter);
testNG.setTestClasses(new Class[] { tests.login.LoginTest.class });
testNG.run();
My tests run using a bunch of parameters defined in the testng.xml file, but this does not pick those parameters up, which is causing the test to fail.
This is the top of my testng.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="tests">
<parameter name="browser" value="firefox" />
<parameter name="url" value="URL goes here!"/>
<parameter name="printToFile" value="false" />
<parameter name="trace" value="false" />
<parameter name="opt" value="true" />
<parameter name="customer" value="Demo" />
<parameter name="network" value="NSG Designated Streets (Type 1/2)" />
<parameter name="buildNo" value="312" />
<listeners>
<listener class-name="listeners.TestNGCustomReportListener" />
</listeners>
<test name="firefoxTest">
<parameter name="browser" value="firefox" />
<parameter name="url" value="URL goes here!" />
<parameter name="printToFile" value="false" />
<parameter name="trace" value="false" />
<parameter name="opt" value="true" />
<parameter name="customer" value="Demo" />
<parameter name="network" value="NSG Designated Streets (Type 1/2)" />
I tried adding @Parameters at the top of the test, as shown here, but that did not work. No parameter was picked up.
public class AutoLogOutTest extends CrossBrowserTest {
@Parameters("url")
@Test(groups = { "all", "login", "simple" })
public void autoLogOut(@Optional("") String url) {
This is described here, but does not work as this author suggests it should: http://toolsqa.com/selenium-webdriver/testng-parameters-data-provider/
For some reason testng 6.4 and up no longer supports parameter inside the method: Is there a way to specify parameters for included methods in TestNG suite.xml?
How can I get my parameters into this test?