Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testng Selenium Grid抛出参数';selenium.host';方法startServer上的@Configuration需要_Testng_Selenium Grid - Fatal编程技术网

Testng Selenium Grid抛出参数';selenium.host';方法startServer上的@Configuration需要

Testng Selenium Grid抛出参数';selenium.host';方法startServer上的@Configuration需要,testng,selenium-grid,Testng,Selenium Grid,在运行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.interna

在运行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)
我的代码:(假设我启动了遥控器并启动了集线器)

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>

//存在所有泛型方法、设置和拆卸方法的基类
//登录相关方法并继承TestBase
//同样,对于另一个浏览器,我们有另一个不同端口号的测试
我的项目和不同站点中给出的其他示例之间的区别是: 我在startServer方法中有@BeforeSuite注释,(@BeforeClass不适用于普通项目(不是网格),因为我在测试中有各种继承的类,所以我将其更改为@BeforeSuite及其工作模式。)


谁能帮我一下吗。。提前感谢

@BeforeTest
适用于此设置。

我在这里没有看到任何提示您正在使用Selenium Grid的内容。你想用什么版本?你有什么网格问题?看起来您只是在启动RC服务器时遇到问题。我正在使用selenium-grid-1.0.8。对于网格,除了启动集线器和远程控制,我们没有做任何具体的事情。。。以及我在testng.xml中给出的那些细节(给出了一个测试示例)。。如果没有网格,我可以运行同一个项目(使用另一个testng1.xml)nirvdrum,您甚至可以告诉我发生以下错误的原因,这就足够了,我可以让它正常工作:org.testng.TestNGException:方法startServer上的@Configuration需要参数'selenium.host'。。当我看代码时,我无法理解这个问题。我认为你的@BeforeSuite可能是问题所在。尝试将selenium.host与用户名和密码参数一起传递,并查看是否出现错误resolved@Unni,这也正是我的观点。这里出现的问题是,您正在使用“BeforeSuite”调用startServer,而它对参数selenium.host没有任何可见性,该参数在测试中给出。这不是一个testNG错误。我相信这就是它的工作方式。我仍然不明白为什么你使用BeforeSuite而不是BeforeTest。根据你的要求,我想应该是“测试前”。我有完全相同的问题,但这并不能解决它!有什么想法吗(
<?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>