problem with webdriver and selenium grid 2

classic Classic list List threaded Threaded
21 messages Options
12
Reply | Threaded
Open this post in threaded view
|

problem with webdriver and selenium grid 2

include85
Hi Tarun,

I have some problem with webdriver and sel grid 2.
I have 5 machines, and each machine 2 instances with FF11, a total of 10 instances that I should run my sel tests webdriver.
When I run the building in Jenkins, the 10 browsers open correctly in 5 machines, but in each window is not tested in full, just log in, or at most a few lines of the test.
Shortly after closes, it opens another, and so on.
It seems that the instructions overlap and all go crazy!
Perhaps session issues or do some problem in startsession or closesession test.

public abstract class TestUITestcase_webdriver {
	//public WebDriver driver = new HtmlUnitDriver();
	protected static WebDriver driver;
	protected String baseUrl;
	
	private static final Map<String,String> AvailableDrivers;
	static {
		Map<String,String> map = new HashMap<String, String>();
		map.put("firefox", "org.openqa.selenium.firefox.FirefoxDriver");
		map.put("chrome", "org.openqa.selenium.chrome.ChromeDriver");
		AvailableDrivers = Collections.unmodifiableMap(map);
	}
	
	@BeforeMethod(alwaysRun = true)
	@Parameters({ "seleniumHubUrl", "browser", "mode", "webSite" })
	protected void startSession(@Optional("http://192.168.1.31:4444/wd/hub") String seleniumHubUrl,
								@Optional("firefox") String browser,
								@Optional("hub") String mode,
								@Optional("http://27.staging.testsite.it") String webSite) throws ConfigurationException
	{
		if (mode.equals("hub")){
			URL HubUrl;
			try {
				HubUrl = new URL(seleniumHubUrl);
			} catch (MalformedURLException e1) {
				throw new ConfigurationException("The url for the selenium hub is invalid");
			}
			DesiredCapabilities capabilities = new DesiredCapabilities();
			capabilities.setBrowserName(browser);
			driver = new RemoteWebDriver(HubUrl,capabilities);
		} else {
			String driverClassName = AvailableDrivers.get(browser);
			if (driverClassName == null) {
				throw new ConfigurationException("The browser parameter passed:"+ browser + " must be one of." +AvailableDrivers.keySet().toArray().toString());
			}
			try {
				driver = (WebDriver) Class.forName(driverClassName).newInstance();
			} catch (Exception e) {
				throw new ConfigurationException("The driver class specified:"+ driverClassName + " is invalid and cannot be instantiated");
			}
		}
		baseUrl = webSite;
		driver.manage().window().setSize(new Dimension(1280, 768));
	}
	
	@AfterMethod(alwaysRun = true)
	protected void closedriver() {
		//driver.close();
		driver.quit();
	}
	
	public static WebDriver getDriverInstance(){
		return driver;
	}

package com.ndg.test.selenium;

@SuppressWarnings("serial")
public class ConfigurationException extends Exception {

	public ConfigurationException(String message) {
		super(message);
	}
}

I can write other code if could be useful to find the bug.

Thanks.
GC
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

softwaretestingforum
Administrator
Hi Guiseppe,

I noticed following line in your WebDriver set up -

protected static WebDriver driver;

My hunch is, static WebDriver instance is suffering from concurrency issue. Since static variable is associated with class and not an instance hence mutiple threads would be trying to change its state and your tests go haywire.

As first remedy, could you change it to -

protected WebDriver driver;

and see how it goes.

~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

include85
Ok, it'll be done tomorrow.

@afterMethod is correct for you?
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

softwaretestingforum
Administrator
I did not see remaining code once I came across "static" variable :-)
In @afterMethod You need not comment "driver.close()". Rest seems fine.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

include85
Thank you very much Tarun, now it works!
This was static
protected WebDriver driver;
 because I had created a function
public WebDriver getDriverInstance() {
	return driver;
}
for sent the driver value in the class screenshot
WebDriver driver = TestUITestcase_webdriver.getDriverInstance();

This line want a static value in the declaration of driver.
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

include85
I have a problem here:

FAILED CONFIGURATION: @BeforeMethod startSession("http://192.168.1.31:4444/wd/hub", "firefox", "hub", "http://27.staging.test.it")
     [java] org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms
...
...
at com.ndg.test.selenium.TestUITestcase_webdriver.startSession(TestUITestcase_webdriver.java:81)

line 81: driver = new RemoteWebDriver(HubUrl,capabilities);

and here:

FAILED CONFIGURATION: @AfterMethod closedriver
     [java] org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
     [java] Build info: version: '2.16.1', revision: '15405', time: '2012-01-05 12:23:54'
     [java] System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_23'
     [java] Driver info: driver.version: RemoteWebDriver
     [java] 	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:432)
     [java] 	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:439)
     [java] 	at org.openqa.selenium.remote.RemoteWebDriver.quit(RemoteWebDriver.java:314)
     [java] 	at com.ndg.test.selenium.TestUITestcase_webdriver.closedriver(TestUITestcase_webdriver.java:101)

line 101: driver.quit();


Why?:(
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

softwaretestingforum
Administrator
I used to have issues with launching more than 3 FF browsers on Windows. What thread count are you using?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

include85
<suite name="Test UI Selenium Test Suite" parallel="methods" thread-count="5" verbose="3" configfailurepolicy="continue">

five..are they too many? :S
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

softwaretestingforum
Administrator
Could you try with "thread-count = 3"

there is also a way to increase time out -

FirefoxBinary fb = new FirefoxBinary();
fb.setTimeout(java.util.concurrent.TimeUnit.SECONDS.toMillis(90));
WebDriver driver = new FirefoxDriver(fb, null); // or pass in a FirefoxProfile you want instead of the default webdriver creates.

Though I never tried it.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

include85
I'm trying..but I have more of 400 tests..only in three machines seems few....
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

include85
I'm very sad....

result of tests:
fail    ok     skip   tot(only for now) 
13	26	188	227

Why?Too many tests with skip status!What's happening Tarun?
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

softwaretestingforum
Administrator
Don't be sad man, it would be solved too :)
I suppose tests are skipped because of configuration failures you pointed at earlier. Is it so?
Also did you reduce thread count and execute test?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

include85
Yes Tarun, the tests are skipped for errors written in previous post.

Summarizing:

Failed to invoke @Configuration method com.ndg.test.selenium.TestUITestcase_webdriver.startSession:Unable to bind to locking port 7054 within 45000 ms

[Invoker 5985705] Invoking @AfterMethod com.ndg.test.selenium.TestUITestcase_webdriver.closedriver()
[java] Failed to invoke @Configuration method com.ndg.test.selenium.TestUITestcase_webdriver.closedriver:null

FAILED CONFIGURATION: @BeforeMethod startSession("http://192.168.1.31:4444/wd/hub", "firefox", "hub", "http://27.staging.test.it")
     [java] org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms
     [java] Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 20:21:18'
     [java] System info: os.name: 'Linux', os.arch: 'i386', os.version: '3.5.0-21-generic', java.version: '1.7.0_09'
     [java] Driver info: driver.version: FirefoxDriver
     [java] Command duration or timeout: 45.63 seconds
     [java] Build info: version: '2.16.1', revision: '15405', time: '2012-01-05 12:23:54'
     [java] System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_23'
     [java] Driver info: driver.version: RemoteWebDriver
     [java] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     [java] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     [java] 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     [java] 	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
     [java] 	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
     [java] 	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
     [java] 	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:435)
     [java] 	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:135)
     [java] 	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
     [java] 	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:102)
     [java] 	at com.ndg.test.selenium.TestUITestcase_webdriver.startSession(TestUITestcase_webdriver.java:81)
     [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [java] 	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:76)
     [java] 	at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
     [java] 	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
     [java] 	at org.testng.internal.Invoker.invokeMethod(Invoker.java:613)
     [java] 	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
     [java] 	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
     [java] 	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
     [java] 	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
     [java] 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
     [java] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
     [java] 	at java.lang.Thread.run(Thread.java:662)
     [java] Caused by: org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms

FAILED CONFIGURATION: @AfterMethod closedriver
     [java] java.lang.NullPointerException
     [java] 	at com.ndg.test.selenium.TestUITestcase_webdriver.closedriver(TestUITestcase_webdriver.java:101)
     [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [java] 	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:76)
     [java] 	at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:525)
     [java] 	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:202)
     [java] 	at org.testng.internal.Invoker.invokeMethod(Invoker.java:757)
     [java] 	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
     [java] 	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
     [java] 	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
     [java] 	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
     [java] 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
     [java] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
     [java] 	at java.lang.Thread.run(Thread.java:662)

These are repeat a lot of time.
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

softwaretestingforum
Administrator
What thread-count have you set?
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

include85
only 3.
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

softwaretestingforum
Administrator
Could you come on Gtalk? difficult to debug in here. I sent you invitation from tkumarb at gmail.com
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

include85
This post was updated on .
Tests work with only 3 counter and with "timeout": 420000 and "browserTimeout": 0
(in last-run only 9 tests had problems before mentioned)!
If I setted 5 counter or "browserTimeout": 300000, I have many problems before mentioned.

Tarun, Could you explain the motive?Do you know? I not!!

ps: whitout set browserTimeout remain some tests/browsers stuck. Do you know how I could find a solution?
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

selenium_tester
Hi Tarun,

I am facing similar problem. My FF browsers are closed. But the nodes are not released.
sometimes, my nodes are released. But test is not completed.

below are the commands I am using. Also attached JSON config files.

webconfig.jsonhubconfig.json
start java -jar selenium-server-standalone-2.28.0.jar -role hub -hubhost XXX-XX -port 4444 -hubConfig hubconfig.json

start java -jar selenium-server-standalone-2.28.0.jar -role webdriver -hub http://XXX-XX:4444/grid/register -port 5561 -browser "browserName=firefox, maxInstances=10" -maxSession 10 -nodeConfig webconfig.json

start java -jar selenium-server-standalone-2.28.0.jar -role webdriver -hub http://XXX-XX:4444/grid/register -port 5560 -browser "browserName=firefox, maxInstances=10" -maxSession 10 -nodeConfig webconfig.json

start java -jar selenium-server-standalone-2.28.0.jar -role webdriver -hub http://XXX-XX:4444/grid/register -port 5562 -browser "browserName=firefox, maxInstances=10" -maxSession 10 -nodeConfig webconfig.json

start java -jar selenium-server-standalone-2.28.0.jar -role webdriver -hub http://XXX-XX:4444/grid/register -port 5563 -browser "browserName=firefox, maxInstances=10" -maxSession 10 -nodeConfig webconfig.json

Kindly suggest I am missing anything.

Thanks,
Srini
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

softwaretestingforum
Administrator
In reply to this post by include85
@GC I suppose the problem is with WebDriver not being able to take control on FF instance when you use too many threads. Something you mentioned earlier -

Failed to invoke @Configuration method com.ndg.test.selenium.TestUITestcase_webdriver.startSession:Unable to bind to locking port 7054 within 45000 ms

Did you try the solution I mentioned earlier about increasing time out -

FirefoxBinary fb = new FirefoxBinary();
fb.setTimeout(java.util.concurrent.TimeUnit.SECONDS.toMillis(90));
WebDriver driver = new FirefoxDriver(fb, null); // or pass in a FirefoxProfile you want instead of the default webdriver creates.
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: problem with webdriver and selenium grid 2

selenium_tester
sure will try and let you know.

Thanks,
Srini

On Mon, Jan 14, 2013 at 11:47 AM, tarunkumar [via Manual and Automated Testing] <[hidden email]> wrote:
@GC I suppose the problem is with WebDriver not being able to take control on FF instance when you use too many threads. Something you mentioned earlier -

Failed to invoke @Configuration method com.ndg.test.selenium.TestUITestcase_webdriver.startSession:Unable to bind to locking port 7054 within 45000 ms

Did you try the solution I mentioned earlier about increasing time out -

FirefoxBinary fb = new FirefoxBinary();
fb.setTimeout(java.util.concurrent.TimeUnit.SECONDS.toMillis(90));
WebDriver driver = new FirefoxDriver(fb, null); // or pass in a FirefoxProfile you want instead of the default webdriver creates.

No Automated Testing




If you reply to this email, your message will be added to the discussion below:
http://manual-and-automated-testing.1070.n6.nabble.com/problem-with-webdriver-and-selenium-grid-2-tp5001623p5001654.html
To unsubscribe from problem with webdriver and selenium grid 2, click here.
NAML

12