Selenium Grid 抛出参数 'selenium.host'方法 startServer 上的 @Configuration 需要 [英] Selenium Grid throws Parameter 'selenium.host' is required by @Configuration on method startServer

查看:30
本文介绍了Selenium Grid 抛出参数 'selenium.host'方法 startServer 上的 @Configuration 需要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行 Selenium Grid 时出现以下异常:

On running Selenium Grid I am getting the below exception:

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)

我的代码:(考虑到我已经启动了远程控制并启动了集线器)

My Code: (Consider i have started remote controls and launched the hub)

@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:

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 及其工作.)

Difference between my project and other example given in various site are : I have @BeforeSuite annotation in the startServer method, (@BeforeClass was not working for a normal project (not a Grid) as i have various inherited classes in a test and so i changed it to @BeforeSuite and its working.)

有人可以帮我吗..提前致谢

Can any one help me please.. Thanks in Advance

推荐答案

@BeforeTest 适用于此设置..

这篇关于Selenium Grid 抛出参数 &amp;#39;selenium.host&amp;#39;方法 startServer 上的 @Configuration 需要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆