1

I am getting an error in simple program, earlier it was working fine, now for some reason I am not able to execute it. I am using selenium 3.0.1 Chrome driver 93.0.4 Please check my code and error below.
It would be appreciated if anyone can help me

My Code:

public class MouseOverDemo {

    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "C:\\SeleniumJars\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        // JavascriptExecutor js = (JavascriptExecutor)driver;
        //driver.get("http://demo.guru99.com/test/drag_drop.html");
        driver.get("https://jqueryui.com/resizable/");
        Actions action = new Actions(driver);

        WebElement resize = driver.findElement(By.cssSelector("body.jquery-ui.page.page-id-43.page-template-default.page-slug-resizable.single-author.singular:nth-child(2) div:nth-child(2) div.clearfix.row:nth-child(3) div.content-right.twelve.columns div:nth-child(1) > iframe.demo-frame:nth-child(5)"));
        driver.switchTo().frame(resize);
        WebElement resize1 = driver.findElement(By.id("resizable"));
        action.moveToElement(resize1, 2500, 2500).build().perform();
        System.out.println("Resize is done");
    
    }

Error:

Starting ChromeDriver 93.0.4577.63 (ff5c0da2ec0adeaed5550e6c7e98417dac77d98a-refs/branch-heads/4577@{#1135}) on port 40273
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Nov. 11, 2021 3:43:35 P.M. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Nov. 11, 2021 3:43:36 P.M. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Nov. 11, 2021 3:43:36 P.M. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {stacktrace=Backtrace:
    Ordinal0 [0x003CD403+2479107]
    Ordinal0 [0x00367D51+2063697]
    Ordinal0 [0x00271F90+1056656]
    Ordinal0 [0x00291A80+1186432]
    Ordinal0 [0x002B58E7+1333479]
    Ordinal0 [0x002B395A+1325402]
    Ordinal0 [0x002B351D+1324317]
    Ordinal0 [0x00254D3F+937279]
    Ordinal0 [0x00255246+938566]
    Ordinal0 [0x00255521+939297]
    GetHandleVerifier [0x0054F3F6+1531734]
    GetHandleVerifier [0x005FE9AE+2249998]
    GetHandleVerifier [0x004539AB+501003]
    GetHandleVerifier [0x00452A29+497033]
    Ordinal0 [0x0036D11D+2085149]
    Ordinal0 [0x00254ADE+936670]
    Ordinal0 [0x002546C0+935616]
    GetHandleVerifier [0x00625E4C+2410924]
    BaseThreadInitThunk [0x765AFA29+25]
    RtlGetAppContainerNamedObjectPath [0x777A7A9E+286]
    RtlGetAppContainerNamedObjectPath [0x777A7A6E+238]
, error=invalid session id, message=invalid session id}
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'DESKTOP-HAH9N6P', ip: '172.16.12.8', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.11'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:375)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:449)
    at org.openqa.selenium.By$ByName.findElement(By.java:303)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360)
    at demoSelenium.Locators.main(Locators.java:21)
Caused by: java.lang.ClassCastException: class com.google.common.collect.Maps$TransformedEntriesMap cannot be cast to class org.openqa.selenium.WebElement (com.google.common.collect.Maps$TransformedEntriesMap and org.openqa.selenium.WebElement are in unnamed module of loader 'app')
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:373)
     4 more
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I would upgrade Selenium to 3.141... (or Selenium 4 which is at stable release status now) delete all dependencies and add them back in... it's a little odd that you have a version of "unknown" in there... Also check chromedriver vs chrome browser version. Major versions should match. (you've got v93 chromedriver so make sure chrome is also v93) – pcalkins Nov 11 '21 at 21:54
  • Thank you for your response... I will try it – Rajpreet Matharu Nov 12 '21 at 01:53
  • @RajpreetMatharu Did you get a chance to look into the [solution](https://stackoverflow.com/a/69935397/7429447) I have offered? Can I get a feedback? – undetected Selenium Nov 12 '21 at 06:20
  • 1
    @DebanjanB, yes , I am able to execute my program but getting new error – Rajpreet Matharu Nov 12 '21 at 13:38
  • SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. – Rajpreet Matharu Nov 12 '21 at 13:38
  • _`SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"`_ sounds to be a new error all together and you may like to raise a new question with all the relevant details. – undetected Selenium Nov 12 '21 at 13:42
  • @DebanjanB, ok I will raise a new question..... Thank you for the help – Rajpreet Matharu Nov 12 '21 at 13:50
  • I think that message is normal... It just means that you haven't implemented logs (which is a new feature of Selenium 4) nop mode means logging is off... does it prevent your run? – pcalkins Nov 12 '21 at 17:11
  • @pcalkins Yes its running properly – Rajpreet Matharu Nov 13 '21 at 21:23

1 Answers1

1

This error message...

Starting ChromeDriver 93.0.4577.63 (ff5c0da2ec0adeaed5550e6c7e98417dac77d98a-refs/branch-heads/4577@{#1135}) on port 40273
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Nov. 11, 2021 3:43:35 P.M. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Nov. 11, 2021 3:43:36 P.M. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Nov. 11, 2021 3:43:36 P.M. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {stacktrace=Backtrace:
    Ordinal0 [0x003CD403+2479107]

...implies that the ChromeDriver was unable to initiate/spawn a new Google Chrome Browsing Context.

Your main issue is the incompatibility between the version of the binaries you are using. Though you are using one of the recent ChromeDriver v93.0.4577.63 but Selenium version is 3.0.1 which is old and ancient.


Solution

Ensure that:

  • JDK is upgraded to current levels JDK 8u311.
  • Selenium is upgraded to current levels Version 4.0.0.
  • ChromeDriver is updated to current ChromeDriver v95.0 level.
  • Chrome is updated to current Chrome Version 95.0 level. (as per ChromeDriver v78.0 release notes)
  • Take a System Reboot.
  • Execute your @Test as non-root user.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352