Skip to main content
Tweeted twitter.com/#!/StackSQA/status/479437686994776064

selenium WebDriver Selenium 2 RemoteWebDriver constructor error: java.lang.String cannot be cast to java.util.Map

more info
Source Link
bhavs
  • 143
  • 1
  • 5

I am newbie with selenium and writing selenium test cases, I am basically trying to modify existing code in order to enhance some functionality.

I am creating a webDriver using the following code :

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName("firefox");
    capabilities.setCapability("key", true);
    capabilities.setCapability("key", "value");
    if (driverUrl != null) {
        System.out.println(" Capabilities are "+capabilities.toString());
        try {
            URL url = new URL(driverUrl);
            System.out.println(" DriverUtil: createDriver() path: "+url.toString()+" protocol "+url.getProtocol()+" hostName :"+url.getHost()+" port "+url.getPort());
            WebDriver driver = new RemoteWebDriver(url, capabilities);
            System.out.println(" WebDriver is "+driver);
            return driver;
        } catch (MalformedURLException e) {
            throw new IllegalStateException("Failed to create remote web driver for url " + driverUrl, e);
        }
    }

The url as well as the capabilities have the following values :

 DriverUtil webDriver is http://xyz-qaa.abc.no
 Capabilities are Capabilities [{browserName=firefox, key=value}]

I have modified the url in this question but as such the url has a valid value and can be opened in the browser.

But when I try to run the test cases I see this :

 Caused by:
        java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
            at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
            at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
            at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
            at heimdall.ui.webtest.DriverUtil.createDriver(DriverUtil.java:46)

I have looked around to find a solution for this but I am unable to find one. Any suggestions?

I am not entirely sure which version of selenium is being used, because I am not the original author, but in te eclipse project I did find that the org.seleniumhq.selenium/selenium-remote-driver/2.32.0.jar and selenium-firefox-driver-2.32.0.jar is being used.

I am newbie with selenium and writing selenium test cases, I am basically trying to modify existing code in order to enhance some functionality.

I am creating a webDriver using the following code :

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName("firefox");
    capabilities.setCapability("key", true);
    capabilities.setCapability("key", "value");
    if (driverUrl != null) {
        System.out.println(" Capabilities are "+capabilities.toString());
        try {
            URL url = new URL(driverUrl);
            System.out.println(" DriverUtil: createDriver() path: "+url.toString()+" protocol "+url.getProtocol()+" hostName :"+url.getHost()+" port "+url.getPort());
            WebDriver driver = new RemoteWebDriver(url, capabilities);
            System.out.println(" WebDriver is "+driver);
            return driver;
        } catch (MalformedURLException e) {
            throw new IllegalStateException("Failed to create remote web driver for url " + driverUrl, e);
        }
    }

The url as well as the capabilities have the following values :

 DriverUtil webDriver is http://xyz-qaa.abc.no
 Capabilities are Capabilities [{browserName=firefox, key=value}]

I have modified the url in this question but as such the url has a valid value and can be opened in the browser.

But when I try to run the test cases I see this :

 Caused by:
        java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
            at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
            at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
            at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
            at heimdall.ui.webtest.DriverUtil.createDriver(DriverUtil.java:46)

I have looked around to find a solution for this but I am unable to find one. Any suggestions?

I am newbie with selenium and writing selenium test cases, I am basically trying to modify existing code in order to enhance some functionality.

I am creating a webDriver using the following code :

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName("firefox");
    capabilities.setCapability("key", true);
    capabilities.setCapability("key", "value");
    if (driverUrl != null) {
        System.out.println(" Capabilities are "+capabilities.toString());
        try {
            URL url = new URL(driverUrl);
            System.out.println(" DriverUtil: createDriver() path: "+url.toString()+" protocol "+url.getProtocol()+" hostName :"+url.getHost()+" port "+url.getPort());
            WebDriver driver = new RemoteWebDriver(url, capabilities);
            System.out.println(" WebDriver is "+driver);
            return driver;
        } catch (MalformedURLException e) {
            throw new IllegalStateException("Failed to create remote web driver for url " + driverUrl, e);
        }
    }

The url as well as the capabilities have the following values :

 DriverUtil webDriver is http://xyz-qaa.abc.no
 Capabilities are Capabilities [{browserName=firefox, key=value}]

I have modified the url in this question but as such the url has a valid value and can be opened in the browser.

But when I try to run the test cases I see this :

 Caused by:
        java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
            at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
            at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
            at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
            at heimdall.ui.webtest.DriverUtil.createDriver(DriverUtil.java:46)

I have looked around to find a solution for this but I am unable to find one. Any suggestions?

I am not entirely sure which version of selenium is being used, because I am not the original author, but in te eclipse project I did find that the org.seleniumhq.selenium/selenium-remote-driver/2.32.0.jar and selenium-firefox-driver-2.32.0.jar is being used.

    DesiredCapabilities capabilities=newcapabilities = new DesiredCapabilities();
      capabilities.setBrowserName("firefox");
      capabilities.setCapability("key", true);
      capabilities.setCapability("key", "value");
    if (driverUrl != null) {
        System.out.println(" Capabilities are "+capabilities.toString());
        try {
            URL url = new URL(driverUrl);
            System.out.println(" DriverUtil: createDriver() path: "+url.toString()+" protocol "+url.getProtocol()+" hostName :"+url.getHost()+" port "+url.getPort());
            WebDriver driver = new RemoteWebDriver(url, capabilities);
            System.out.println(" WebDriver is "+driver);
            return driver;
        } catch (MalformedURLException e) {
            throw new IllegalStateException("Failed to create remote web driver for url " + driverUrl, e);
        }
    }

Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:111) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129) at heimdall.ui.webtest.DriverUtil.createDriver(DriverUtil.java:46)

 Caused by:
        java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
            at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
            at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
            at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
            at heimdall.ui.webtest.DriverUtil.createDriver(DriverUtil.java:46)
    DesiredCapabilities capabilities=new DesiredCapabilities();
      capabilities.setBrowserName("firefox");
      capabilities.setCapability("key", true);
      capabilities.setCapability("key", "value");
    if (driverUrl != null) {
  System.out.println(" Capabilities are "+capabilities.toString());
        try {
            URL url = new URL(driverUrl);
            System.out.println(" DriverUtil: createDriver() path: "+url.toString()+" protocol "+url.getProtocol()+" hostName :"+url.getHost()+" port "+url.getPort());
            WebDriver driver = new RemoteWebDriver(url, capabilities);
            System.out.println(" WebDriver is "+driver);
            return driver;
        } catch (MalformedURLException e) {
            throw new IllegalStateException("Failed to create remote web driver for url " + driverUrl, e);
        }
    }

Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:111) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129) at heimdall.ui.webtest.DriverUtil.createDriver(DriverUtil.java:46)

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setBrowserName("firefox");
    capabilities.setCapability("key", true);
    capabilities.setCapability("key", "value");
    if (driverUrl != null) {
        System.out.println(" Capabilities are "+capabilities.toString());
        try {
            URL url = new URL(driverUrl);
            System.out.println(" DriverUtil: createDriver() path: "+url.toString()+" protocol "+url.getProtocol()+" hostName :"+url.getHost()+" port "+url.getPort());
            WebDriver driver = new RemoteWebDriver(url, capabilities);
            System.out.println(" WebDriver is "+driver);
            return driver;
        } catch (MalformedURLException e) {
            throw new IllegalStateException("Failed to create remote web driver for url " + driverUrl, e);
        }
    }
 Caused by:
        java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
            at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:218)
            at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:111)
            at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
            at heimdall.ui.webtest.DriverUtil.createDriver(DriverUtil.java:46)
Source Link
bhavs
  • 143
  • 1
  • 5
Loading