在运行Selenium Grid时,我得到以下异常:
org.testng.TestNGException:
Parameter 'selenium.host' is required by @Configuration on method startServer
but has not been marked @Optional or defined in D:\workspace\ALM05_PA\config\gridSuite.xml
at org.testng.internal.Parameters.createParameters(Parameters.java:144)
at org.testng.internal.Parameters.createParameters(Parameters.java:342)
at org.testng.internal.Parameters.createConfigurationParameters(Parameters.java:78)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:191)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:131)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:278)
at org.testng.SuiteRunner.run(SuiteRunner.java:241)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1169)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1094)
at org.testng.TestNG.run(TestNG.java:1006)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:107)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:199)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:170)
我的代码:(考虑我已启动远程控制并启动了中心)
@BeforeSuite(alwaysRun = true)
@Parameters({"selenium.host", "selenium.port", "selenium.browser", "selenium.url" })
public void startServer(String host, String port, String browser, String url, String SEARCH_STRING) throws Exception {
selenium = new DefaultSelenium(host, Integer.parseInt(port), browser, url);
selenium.start();
}
的testng.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="SL-Grid" parallel="tests">
<parameter name="username" value="test" />
<parameter name="password" value="test1" />
<test name="SL-Chrome" preserve-order="true">
<parameter name="selenium.host" value="localhost"></parameter>
<parameter name="selenium.port" value="5555"></parameter>
<parameter name="selenium.browser" value="*googlechrome"></parameter>
<parameter name="selenium.url" value="http://properurl:8080/"></parameter>
<classes>
<class name="com.TestBase" /> // Base class where all generic methods, setUp and tearDown methods present
<class name="com.Login"> // Login related methods and inherit TestBase
<methods>
<include name="loginPage" />
<include name="signIn" />
</methods>
</class>
<class name="com.Page1">
<methods>
<include name="clickLinkA" />
<include name="isTextBoxXXXPresent" />
</methods> </class></classes></test>
// same way for another browser we have another test with varied port number
</suite>
我的项目与各个站点中给出的其他示例之间的区别是: 我在startServer方法中有@BeforeSuite注释,(@ BeforeClass不适用于普通项目(不是网格),因为我在测试中有各种继承类,因此我将其更改为@BeforeSuite及其工作。)
任何人都可以帮助我..在此先感谢
答案 0 :(得分:0)
@BeforeTest
适用于此设置..