Can set the Display of firefox binary for Remote machine

1,041 views
Skip to first unread message

DC

unread,
Nov 15, 2012, 8:23:16 AM11/15/12
to webd...@googlegroups.com
Hi,
 
I need to run my test on one of my LINUX(HUB and Node running on same box) by trigger tests from CI box. For that purpose i wanted to set the DISPLAY for the FF binary.
 
Below is the code i have used, but i am getting exception
 
//Code
 
DesiredCapabilities Capabilities = null;
System.setProperty("webdriver.firefox.bin", "/usr/local/firefox/15.0.1/firefox"); //Path of FF binary
(Not sure how to set the path on Remote box)
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.setEnvironmentProperty("DISPLAY", ":4");
FirefoxProfile profile = new FirefoxProfile();
//..
 
Capabilities = DesiredCapabilities.firefox();
Capabilities.setCapability(FirefoxDriver.PROFILE, profile);
Capabilities.setCapability(FirefoxDriver.BINARY, firefoxBinary);
Capabilities.setJavascriptEnabled(true);
Capabilities.setPlatform(Platform.LINUX);
Capabilities.setBrowserName("firefox");
Capabilities.setVersion("15");

 WebDriver driver =
     new RemoteWebDriver(new URL("http://xyz:4444/wd/hub/"), Capabilities);
 
Exception:

Exception in thread "main"

org.openqa.selenium.WebDriverException: java.util.HashMap cannot be cast to java.lang.String

Command duration or timeout: 1.58 seconds

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 17:28:14'

System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_03'

Driver info: driver.version: RemoteWebDriver

Mike Riley

unread,
Nov 15, 2012, 6:27:31 PM11/15/12
to webd...@googlegroups.com
Firefox 15 was not supporter until version 2.26.0 of Selenium.  Maybe updating your Selenium will fix the problem.

In Linux I would think it would inherit the DISPLAY setting from the server that starts the browser though.  Just a thought.

Mike

DC

unread,
Nov 15, 2012, 11:40:08 PM11/15/12
to webd...@googlegroups.com
Thanks Mike!!!

Krishnan Mahadevan

unread,
Nov 16, 2012, 1:17:17 AM11/16/12
to webd...@googlegroups.com
Mike,
That still doesnt explain this exception : org.openqa.selenium.WebDriverException: java.util.HashMap cannot be cast to java.lang.String

DC,
Can you please share your complete stacktrace. First look at this error and I feel that there was a problem when internally RemoteWebDriver tried converting your capabilities into a hashmap.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/1FdfcLEIMHwJ.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.

Debabrata Chakraborty

unread,
Nov 21, 2012, 4:36:28 AM11/21/12
to webd...@googlegroups.com
Thanks for replying..
 
Here is the stacktrace:

Exception in thread "main"

org.openqa.selenium.WebDriverException
: java.util.HashMap cannot be cast to java.lang.String

Command duration or timeout: 2.29 seconds

Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 17:28:14'

System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_03'

Driver info: driver.version: RemoteWebDriver

Session ID:

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(

Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at org.openqa.selenium.remote.ErrorHandler.createThrowable(

ErrorHandler.java:188)

at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(

ErrorHandler.java:145)

at org.openqa.selenium.remote.RemoteWebDriver.execute(

RemoteWebDriver.java:472)

at org.openqa.selenium.remote.RemoteWebDriver.startSession(

RemoteWebDriver.java:155)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(

RemoteWebDriver.java:107)

at org.openqa.selenium.remote.RemoteWebDriver.<init>(

RemoteWebDriver.java:115)

at TrailAndTest.MainClass.main(

MainClass.java:154)

Caused by:

java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String

at org.openqa.selenium.firefox.FirefoxDriver.getBinary(

FirefoxDriver.java:167)

at org.openqa.selenium.firefox.FirefoxDriver.<init>(

FirefoxDriver.java:100)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(

Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(

NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(

DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(

Constructor.java:532)

at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(

DefaultDriverFactory.java:57)

at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(

DefaultDriverFactory.java:51)

at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(

DefaultSession.java:196)

at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(

DefaultSession.java:1)

at java.util.concurrent.FutureTask$Sync.innerRun(

FutureTask.java:334)

at java.util.concurrent.FutureTask.run(

FutureTask.java:166)

at org.openqa.selenium.remote.server.DefaultSession$1.run(

DefaultSession.java:150)

at java.util.concurrent.ThreadPoolExecutor.runWorker(

ThreadPoolExecutor.java:1110)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(

ThreadPoolExecutor.java:603)

at java.lang.Thread.run(

Thread.java:679)

--
Thanks,
Debabrata

Debabrata Chakraborty

unread,
Nov 21, 2012, 4:40:15 AM11/21/12
to webd...@googlegroups.com
Hi kamalakar vadla .
 
I haven't got the solution.
 
Thanks,
Debabrata

On Fri, Nov 16, 2012 at 5:00 PM, kamalakar vadla <vkcha...@gmail.com> wrote:
Hi DC ,

How did u solved this issue?

I am using selenium 2.26 .jar


My Code:


public static void main(String[] args) throws IOException {
       
       
        RemoteWebDriver rdriver= null;

        // Setup firefox binary to start in Xvfb       
        String Xport = System.getProperty("lmportal.xvfb.id", ":1");
       final File firefoxPath = new File(System.getProperty("lmportal.deploy.firefox.path", "/usr/bin/firefox"));
        FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath);
        firefoxBinary.setEnvironmentProperty("DISPLAY", Xport);

        // Start Firefox driver
        //WebDriver driver = new FirefoxDriver(firefoxBinary, null);
       
        DesiredCapabilities capability = null;
        capability = DesiredCapabilities.firefox();
        capability.setCapability(FirefoxDriver.BINARY, firefoxBinary);
  
       
       
        capability.setJavascriptEnabled(true);
       
        rdriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
       
       
        rdriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.get("http://google.com/");
  

        // Take snapshot of browser
        File srcFile = ((TakesScreenshot)rdriver).getScreenshotAs(OutputType.FILE);
        FileUtils.copyFile(srcFile, new File("ffsnapshot1.png"));
        rdriver.quit();





Issue :
 stack trace :

  xception in thread "main" org.openqa.selenium.WebDriverException: java.util.HashMap cannot be cast to java.lang.String
Command duration or timeout: 191 milliseconds
Build info: version: '2.26.0', revision: '18041', time: '2012-11-01 19:33:38'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-30-generic', java.version: '1.6.0_29'

Driver info: driver.version: RemoteWebDriver
Session ID:
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:531)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:215)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
    at com.socialtwist.taf.webdriver.Test.main(Test.java:44)
Caused by: java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String
    at org.openqa.selenium.firefox.FirefoxDriver.getBinary(FirefoxDriver.java:171)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:99)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.server.DefaultDriverFactory.callConstructor(DefaultDriverFactory.java:57)
    at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:51)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:196)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:150)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/AvnOLkYbkyYJ.

To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.



--
Thanks,
Debabrata

Mike Riley

unread,
Nov 26, 2012, 5:55:55 PM11/26/12
to webd...@googlegroups.com
Are you using the Java from Oracle on this system, or the OpenJDK version that a lot of Linux distributions install by default?

I always make sure to replace the OpenJDK with the genuine Oracle version, since that is (supposed to be) the same as far as feature support going from one OS to another.  The OpenJDK seems to have some features missing, or simply lags the release of features in the Oracle version.

I can't say that explains it, but it is worth checking.

Mike

Debabrata Chakraborty

unread,
Nov 27, 2012, 12:12:59 AM11/27/12
to webd...@googlegroups.com
Thanks for your suggestion.. But i am using Official version of Java, i checked.
 
Thanks,
Debabrata

To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/kVig31IhJlMJ.

To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.



--
Thanks,
Debabrata
Reply all
Reply to author
Forward
0 new messages