我想在两台不同的机器上运行我的代码(到目前为止,我已经将我的本地机器注册为集线器和 2 个节点),所以在运行 testng.xml 文件时我遇到了错误。
运行 testng.xml 文件时出现错误,应用程序出现错误:- 请查看我的 testng.xml 文件和下面给出的代码:-
My testng.xml file is:-
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" thread-count="4" parallel="tests">
<test name="PVR Test">
<parameter name="remoteurl" value="http://localhost:5555/wd/hub" />
<classes>
<class name="dd_testcases.login">
<methods>
<include name="banner_check" />
</methods>
</class>
</classes>
</test> <!-- Test -->
<test name="footersection">
<parameter name="remoteurl" value="http://localhost:5556/wd/hub" />
<classes>
<class name="dd_testcases.News_General_Footer">
<methods>
<include name="News_General_Footer" />
</methods>
</class>
</classes>
</test>
Test
</suite> <!-- Suite -->
and my code is :-
@BeforeSuite
@Parameters("remoteurl")
public void init(String remoteurl) throws IOException, InterruptedException{
//BasicConfigurator.configure();
dbcon=new sqldbconfig();
logs=Logger.getLogger("PVR");
config=new Properties();
OR=new Properties();
if (driver==null){
InputStream is = getClass().getResourceAsStream("/config.properties");
config.load(is);
//fis=new FileInputStream(config.getProperty("confpath"));
fis=new FileInputStream(System.getProperty("user.dir")+config.getProperty("ORpath"));
//fis=new FileInputStream(System.getProperty("user.dir")+"\\src\\dd_properties\\OR.properties");
OR.load(fis);
//fis=new FileInputStream(config.getProperty("xlspath"));
excel=new Xls_Reader(System.getProperty("user.dir")+config.getProperty("xlspath"));
System.out.println("Browser:: "+config.getProperty("Browser"));
if (config.getProperty("Browser").equalsIgnoreCase("Mozilla")){
cap=DesiredCapabilities.firefox();
cap.setBrowserName("firefox");
cap.setPlatform(Platform.ANY);
}
else if(config.getProperty("Browser").equalsIgnoreCase("chrome")){
cap=DesiredCapabilities.chrome();
cap.setBrowserName("chrome");
cap.setPlatform(Platform.ANY);
}
driver=new RemoteWebDriver(new URL(remoteurl),cap);
driver.get(config.getProperty("testurl"));
and when i run via testng.xml file code throws error:-
org.testng.TestNGException:
Parameter 'remoteurl' is required by @Configuration on method init but has not been marked @Optional or defined
in C:\Users\HT1\workspace\PVRGrid-A\testng.xml
at org.testng.internal.Parameters.createParameters(Parameters.java:148)
at org.testng.internal.Parameters.createParameters(Parameters.java:361)
at org.testng.internal.Parameters.createConfigurationParameters(Parameters.java:84)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:197)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:296)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
at org.testng.TestNG.run(TestNG.java:1018)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Please help me.....what i am doing wrong....