开发者

Selenium Grid throws Parameter 'selenium.host' is required by @Configuration on method startServer

开发者 https://www.devze.com 2023-03-23 10:33 出处:网络
On running Selenium Grid I am getting the below exception: org.testng.TestNGException: Parameter \'selenium.host\' is required by @Configuration on method startServer

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:

<?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="p开发者_开发知识库assword" 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>

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 works for this setup..

0

精彩评论

暂无评论...
验证码 换一张
取 消