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

2,294 views
Skip to first unread message

unni

unread,
Jul 28, 2011, 2:31:42 AM7/28/11
to Selenium Users
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="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>

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

Scal

unread,
Jul 28, 2011, 9:38:04 AM7/28/11
to Selenium Users
Can't see something wrong with a quick look at your code, perhaps try
the TestNG group. Cedric is very active and helpful!

Tarun Bhadauria

unread,
Jul 28, 2011, 9:54:43 AM7/28/11
to seleniu...@googlegroups.com
This looks a little fishy to me -


@Parameters({"selenium.host", "selenium.port", "selenium.browser",
"selenium.url" })
public void startServer(String host, String port, String browser,
String url, String SEARCH_STRING)

See the SEARCH_STRING is not part of parameter list. Though your error message looks misleading. Yet...

~tarun
http://seleniumsoftwaretesting.blogspot.com/

unni

unread,
Jul 29, 2011, 3:20:54 AM7/29/11
to seleniu...@googlegroups.com
Yes I agree its a mistake. i should have deleted the SEARCH_STRING before pasting here. I deleted that from testng.xml and missed from the method.. NOTHING to do with the parameter..

I found that the issue is because of "BeforeSuite" annotation and replaced with "BeforeTest" but now problem is:

running Grid am getting repeatedly the below issues for various run which include 2 browsers. 1) ERROR Server Exception: sessionId should not be null; has this session been started yet? (confirmed that RC is running- THIS PARTICULAR EXCEPTION ALWAYS OCCUR FOR ONE BROWSER RANDOM-WISE IN A RUN, which means only one browser at least start with an application and end up with the below issues, 2 & 3) 2) SeleniumException: Permission denied 3) java.lang.RuntimeException: result was neither 'true' nor 'false':

can any one help me
Message has been deleted

Ross Patterson

unread,
Jul 29, 2011, 8:55:06 AM7/29/11
to seleniu...@googlegroups.com

There is a lot of garbage sent to this list, so it is moderated.  If you want instant gratification, especially when you’ve never posted to the group before, you’ll have to try Google. 

 

Or, as you already did, try Stack Overflow: http://stackoverflow.com/questions/6843575/selenium-grid-throws-parameter-selenium-host-is-required-by-configuration-on-m.  You got a definitive answer from the maintainer of Selenium Grid and good one from someone else.

 

Ross

 

From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of unni
Sent: Friday, July 29, 2011 6:51 AM
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: Selenium Grid throws "Parameter 'selenium.host' is required by @Configuration on method startServer"

 

to display the REPLY this forum takes so much time , which ultimately kills the point of creating the question. People ask question to get reply soon and resolve it in their end. So they escape from Managers. You  are not allowing users to post thread and reply back to get the solution soon Because of your delay of evaluation to display the content posted by users . PLEASE display the post and reply ASAP and will help users to get the solution.... I have replied for this post in the morning yet its not displayed here and how can i get the solution then. If am not getting the solution soon what is the use of this forum...

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/xtEU-qt6qZMJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Krishnan Mahadevan

unread,
Jul 29, 2011, 9:15:11 AM7/29/11
to seleniu...@googlegroups.com
@Unni,

Are you sure, its not  because of an incorrect usage of TestNG ?
Here's a simple testng example which was able to generate a similar error as yours. (The exception stack trace seems to be pointing you towards a testng validation on the parameter count)

Your exception stacktrace:

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


Sample Code:
package testcode;

import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class SimpleParameterErrorShowCaser {
    @BeforeSuite(alwaysRun = true)
    @Parameters({ "selenium.host", "selenium.port" })
    public void startServer(String host, String port, String browser) throws Exception {
        System.out.println(host);
        System.out.println(port);
        System.out.println(browser);
    }
    @Test
    public void runner(){
        System.out.println("hello world");
    }
}

my testng xml file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
    <test name="Test" preserve-order="false">

        <parameter name="selenium.host" value="localhost"></parameter>
        <parameter name="selenium.port" value="5555"></parameter>
        <classes>
            <class name="testcode.SimpleParameterErrorShowCaser" />
        </classes>
    </test>
</suite>

Error that I see :

org.testng.TestNGException:
Method startServer requires 3 parameters but 2 were supplied in the @Configuration annotation.
    at org.testng.internal.Parameters.checkParameterTypes(Parameters.java:187)
    at org.testng.internal.Parameters.createParameters(Parameters.java:123)

    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:192)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:132)

    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 Question for you:
In your testng.xml file I am seeing you specify the following 4 parameters in your test

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


But in your configuration method you seem to be referrring to another one more extra parameter

@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();
    }

Could this be a problem ?


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

unni

unread,
Aug 1, 2011, 12:59:25 AM8/1/11
to seleniu...@googlegroups.com
Hi Krishnan, Please refer my reply to Tarun. Its a mistake of pasting the code here. Actual code looks like:

  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" />
    <parameter name="SEARCH_STRING" value="practice" />


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

<test name="SL-Firefox" preserve-order="true">
    <parameter name="selenium.host" value="localhost"></parameter>
        <parameter name="selenium.port" value="5555"></parameter>
        <parameter name="selenium.browser" value="*firefox"></
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>

</suite>

code:


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

//providing class level access to searchString
            TestBase.SEARCH_STRING=SEARCH_STRING;  //its just for my use


        selenium = new DefaultSelenium(host, Integer.parseInt(port),
browser, url);
        selenium.start();
    }

By using the above code i used to get "Parameter 'selenium.host' is required by
@Configuration on method startServer" and changed it to @BeforeTest (suggested by A.J) and started working but with below issues:

Running Grid am getting repeatedly the below issues for various run which include 2 browsers.
1) ERROR Server Exception: sessionId should not be null; has this session been started yet? (confirmed that RC is running- THIS PARTICULAR EXCEPTION ALWAYS OCCUR FOR ONE BROWSER RANDOM-WISE IN A RUN, which means only one browser at least start with an application and end up with the below issues, 2 & 3)
2) SeleniumException: Permission denied
3) java.lang.RuntimeException: result was neither 'true' nor 'false':


Please help me

Krishnan Mahadevan

unread,
Aug 1, 2011, 3:14:48 AM8/1/11
to seleniu...@googlegroups.com
Unni,

Here's a trimmed down version of the same thing that you are trying to do. I was able to get it working. Perhaps that can help you out.

my testng xml file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="tests">
    <test name="TestFirefox" preserve-order="false">

        <parameter name="selenium.host" value="localhost"></parameter>
        <parameter name="selenium.port" value="4444"></parameter>

        <parameter name="selenium.browser" value="*firefox" />
        <classes>
            <class name="selenium.users.forum.TestAmazon" />
        </classes>
    </test>
    <test name="TestIE" preserve-order="false">

        <parameter name="selenium.host" value="localhost" />
        <parameter name="selenium.port" value="4444" />
        <parameter name="selenium.browser" value="*iexplore" />
        <classes>
            <class name="selenium.users.forum.TestFaceBook" />
        </classes>
    </test>
</suite>

TestAmazon.java
package selenium.users.forum;

import org.testng.Assert;
import org.testng.annotations.Test;

public class TestAmazon extends MyBaseClass{
    @Test
    public void testYahoo(){
        selenium.open("https://www.amazon.com");
        selenium.click("//a[contains(text(),'Start here')]");
        selenium.waitForPageToLoad("15000");
        Assert.assertEquals("Amazon.com Sign In", selenium.getTitle());
    }
}

TestFaceBook.java
package selenium.users.forum;

import org.testng.Assert;
import org.testng.annotations.Test;

public class TestFaceBook extends MyBaseClass{
    @Test
    public void testFB(){
        selenium.open("http://www.facebook.com");
        selenium.waitForPageToLoad("15000");
        selenium.click("//a[contains(text(),'Create a Page')]");
        selenium.waitForPageToLoad("15000");
        Assert.assertEquals("Create a Page | Facebook", selenium.getTitle());
        selenium.click("//img[@class='fb_logo img']");
        selenium.waitForPageToLoad("15000");
        Assert.assertEquals("Welcome to Facebook - Log In, Sign Up or Learn More", selenium.getTitle());
    }
}

MyBaseClass.java
package selenium.users.forum;

import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;

public class MyBaseClass {
    protected Selenium selenium = null;

    @BeforeTest(alwaysRun = true)
    @Parameters({ "selenium.host", "selenium.port", "selenium.browser" })
    public void setup(String host, String port, String browser) {
        selenium = new DefaultSelenium(host, Integer.parseInt(port), browser, "http://google.com");
        selenium.start();
    }

    @AfterTest
    public void shutDown() {
        if (selenium != null) {
            selenium.stop();

        }
    }
}


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/CGEsc2woK3IJ.

unni

unread,
Aug 1, 2011, 6:18:22 AM8/1/11
to seleniu...@googlegroups.com
Thanks Krishnan. surely i will try the same...

Now i figured out that Parallel run throw these error (com.thoughtworks.selenium.SeleniumException: ERROR Server Exception: sessionId should not be null; has this session been started yet?) but Sequential run works well by replacing parallel="tests" to <suite name="Suite" parallel="false"> .  Atleast Grid works sequentially and am relieved :)

Can you please figured out why parallel testing is getting failed with below exception for any one browser as stated earlier discussions: com.thoughtworks.selenium.SeleniumException:
ERROR Server Exception: sessionId should not be null; has this session been started yet?

Krishnan Mahadevan

unread,
Aug 1, 2011, 6:25:47 AM8/1/11
to seleniu...@googlegroups.com
Parallel shouldn't be a problem, if you are not directly dealing with the Selenium object by instantiating it but instead getting the value from a threadedlocal variable

So you would essentially do something as below.

ThreadedLocal<Selenium> myselenium = new ThreadedLocal<Selenium>();
Selenium s = new DefaultSelenium(...);
myselenium.set(s);

Have a method which will query the threaded selenium variable and get the value from it, instead of spawning it.

That is one way I can think of.



Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/DQ9HJWIg7nIJ.

unni

unread,
Aug 1, 2011, 8:54:00 AM8/1/11
to seleniu...@googlegroups.com
Thanks Krishnan for prompt reply...  i have checked ThreadLocal class in http://anublog.colombounplug.com/2009/08/best-use-of-threadlocal-class-to-handle-selenium-session/ but not able to derive solution since am new to selenium.  Also its required more coding :(

Can't we use TestNG parallelism like parallel="tests"? I read Parallel test working for Selenium Grid + TestNG. But for me i get the error i mentioned already... Is it possible to solve in easy manner? 

Or Can you please provide me the solution by applying ThreadLocal concept into my Class, TestBase - where startServer method reside.


unni

unread,
Aug 9, 2011, 1:14:56 AM8/9/11
to seleniu...@googlegroups.com
Krishnan, can you please help me out in succeeding in Parallel Testing.

Amol Darfade

unread,
Dec 19, 2013, 6:11:56 AM12/19/13
to seleniu...@googlegroups.com

Getting follwing error :
Parameter 'browser' is required by @Test on method beforeClass but has not been marked @Optional or defined
Reply all
Reply to author
Forward
0 new messages