question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

[šŸ› Bug]: Grid Protocol Converter Insufficient

See original GitHub issue

What happened?

Java Bindings and the Grid are maintaining a lot of extra code in order to be backwards compatible with earlier versions of Selenium. Except we donā€™t have any tests to show weā€™ve been successful with this. I ran the old Watir-WebDriver tests using the final version of Se2 for the Ruby bindings against the latest Grid, and 40% of them failed.

Updated Update

Found several more issues in Java bindings for OSS code; there are 3 categories:

  1. Stuff that was broken in Grid 4 with the Locator Conversions (name, id & class name locators)
  2. Stuff that was broken in Server 3.7 when translating JWP/early W3C to W3C (switchToWindow & sendKeysToActiveElement) ā€” broken running Java bindings 2.53.1
  3. Stuff that was broken in Server 3.7 when translating pre-W3C JWP to W3C (locators except id & name, implicitlyWait, setScriptTimeout and switchToFrame) ā€” broken running Java bindings 2.45.0 or other bindings 2.53.1

This is now looking like a lot more work to fix; and less likely that people are making as much use of the protocol translations as weā€™ve thought.

Update

  • ~The two things definitely affecting the Java bindings actually look like they might be simple to fix~
  • Iā€™ve never seen a framework that didnā€™t have a way to check if an element wasnā€™t there, and didnā€™t use id/name/class name to do so, which indicates to me that no one has tried to run their 2.x code on a 4.x server, otherwise theyā€™d have raised an issue.
  • No one using Selenium 2 could use Selenium 3 server and switch windows since v3.6 (August 2017), which small sample size, but Iā€™ve never worked anywhere that I didnā€™t need to switch windows for my test suites.
  • I was surprised that Selenium Server 2.53 was able to run latest Chrome version so well. If all you care about is Chrome and/or anything working, thereā€™s zero reason to upgrade off of Server 2.53 right now, (which would explain why there are still so many downloads of it).
  • Whatever we end up doing, I donā€™t think it is unreasonable that running tests on the latest versions of (non-Chrome) browsers should require updating to a version of Selenium > 3.9 when w3c was pretty much finalized, in February 2018.

Uploaded a repo with 13 failing JWP tests with Grid 4 (and 1 failing JWP test with Server v3 for completeness) https://github.com/titusfortner/grid4conversion/tree/main/src/test/java/com/titusfortner/grid4conversion

Options

  1. File these as bugs and fix/ignore as time allows until we do a non-backward compatible rewrite in Selenium 5
  2. Fix these bugs ASAP and then separate out all the protocol conversion code and provide it the same way we do with leg-rc package
  3. Consider it a sunk cost, and just delete all of it now so we can simplify the code and make forward progress

Someone suggested to me that we should proceed with option 3 and if any user really wants option 2, they can pay us/someone to do it, and that makes sense to me with limited resources.

Supporting Data

Here are the different combinations I tested with old watir-webdriver specs using Selenium 2.53.4 Ruby bindings with the latest versions of the browsers and the latest versions Selenium (toggling OSS mode on/off in Se 3/4 for Chrome)

Browser Local Se 2 Se 3 Se 3 OSS Se 4 Se 4 OSS Total Tests
Chrome 3 1 356 3 489 117 1235
Firefox N/A N/A 364 N/A 516 N/A 1244
Safari N/A N/A 302 N/A 404 N/A 1120

Things that are broken when running Bindings 2.53.x

  • Return JavaScriptEnabled as part of capabilities (Ruby only ā€”Ā wonā€™t even try to execute JS if not in caps)
  • Ensure Window ā€œnameā€ parameter is updated to ā€œhandleā€ (Java & Ruby)
  • Delete null values from Cookie arguments (Ruby only ā€”Ā Java deletes null params before sending)
  • ~Translate click actions with bodies into correct actions (e.g., {"button": 2})~ (This was broken for Selenium Server 3.x but fixed in Grid 4)
  • Translate moveTo commands with x/y offsets (Ruby only ā€”Ā Ruby sends null element for just moveTo, Java omits it)
  • Using id or name to locate a missing element will throw the wrong error (Java & Ruby)
  • Using class name to locate an element gives unable to determine locator strategy (Java & Ruby)
  • Sending Key to Active Element gives UnsupportedCommandException (Java & Ruby)

Things that are broken when running Java Bindings 2.45 (or later for other bindings):

  • Using css selector, xpath, tag name, link text, or partial link text values canā€™t be converted to Web Element
  • Setting script timeout ā€“> Cannot call non W3C standard command while in W3C mode
  • Setting implicit wait timeout ā€”> Cannot call non W3C standard command while in W3C mode
  • Switching to Frame by Name ā€”> invalid argument: ā€˜idā€™ can not be string

(Watir doesnā€™t do a whole lot with actions, so itā€™s ~likely~ possible ~a bunch of~ more things are broken in the translation)

@asolntsev is going to try to help us out by running the same experiment with old Selenide test suite for Java. That might tell us more about how bad the situation is. Itā€™s possible that other bindings will have fewer issues.

My guess though is that our assumption that Selenium 2 Bindings users can use Selenium 3 Server or Selenium 4 Grid is misguided, and that people still using Selenium 2 are using Selenium 2 server, and we would be better off removing the translation code rather than fixing it.

How can we reproduce the issue?

Ruby can be reproduced by running watir-webdriver 0.9.3 watirspecs with selenium-webdriver 2.53.4 setting REMOTE, and updating the server start code. Java with JUnit 5:

    @Test
    void getWindow() {
        Set<String> windowHandles = driver.getWindowHandles();
        String handle = windowHandles.stream().findFirst().get();

        Assertions.assertDoesNotThrow(() -> driver.switchTo().window(handle));
    }

    @Test
    void useIDForMissingElement() {
        NoSuchElementException thrown = Assertions.assertThrows(NoSuchElementException.class, () -> {
            driver.findElement(By.id("not-there"));
        });

        String msg = "no such element: Unable to locate element: {\"method\":\"id\",\"selector\":\"not-there\"}";
        Assertions.assertTrue(thrown.getMessage().contains(msg));
    }

Relevant log output

Caused by: org.openqa.selenium.WebDriverException: Returned value cannot be converted to WebElement: {stacktrace=java.lang.RuntimeException: Unable to execute request for an existing session: An unknown error has occurred

and

org.opentest4j.AssertionFailedError: Unexpected exception thrown: org.openqa.selenium.WebDriverException: invalid argument: 'handle' must be a string

Operating System

MacOS Big Sur

Selenium version

Ruby 2.53.4 & Java 2.45.0 & Java 2.53.1

What are the browser(s) and version(s) where you see this issue?

Chrome, Firefox, Safari

What are the browser driver(s) and version(s) where you see this issue?

Latest

Are you using Selenium Grid?

4.1.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
titusfortnercommented, Aug 9, 2022

Ah, yes, for those, youā€™ll need to construct your own MutableCapabilities instance. Itā€™s likely weā€™ll eventually deprecate DesiredCapabilities from RemoteWebDriver like we did local driver classes, but will continue to support MutableCapabilities.

Please find us on Slack/IRC to discuss more: https://www.selenium.dev/support/#ChatRoom

1reaction
titusfortnercommented, Jun 6, 2022

It will still work. The deprecation notices are much more eager than we realized when we released.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grid Control Gets Metric Collection Error On ASM Database
The status of the ASM instance in the Grid Control console shows up as "Unavailable". The ASM home page shows a Metric Collection...
Read more >
Grid partitioning error. - SU2 - CFD Online
Hi, I have compiled the latest version of the code from github and was trying to run the DPW tutorial in parallel.
Read more >
Event Messages - SMA
There is not enough power at the DC input of the inverter for stable operation. ... If all inverters display this event message,...
Read more >
Insufficient permissions to create or access the
I'm trying to convert a Windows NT 4 machine, but after 99% of conversion, I get an error saying "Insufficient permissions to create...
Read more >
Troubleshoot instance launch issues - AWS Documentation
Insufficient instance capacity. Description. You get the InsufficientInstanceCapacity error when you try to launch a new instance or restart a stopped instance.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found