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]: HasAuthentication is not working for Chromium browsers when they are executed in Selenium Grid

See original GitHub issue

What happened?

I am able to use register method from HasAuthentication interface using chromium drivers running on local machine. But when i try to use chromium browser (edge/chrome) which is part of selenium grid I am getting the following error when I try to use HasAuthentication interface.

Code where the test fails: ((HasAuthentication) webDriver).register(() -> new UsernameAndPassword("admin", "admin"));

Error:

java.lang.ClassCastException: class org.openqa.selenium.remote.RemoteWebDriver$ByteBuddy$gPlLDnEY cannot be cast to class org.openqa.selenium.HasAuthentication (org.openqa.selenium.remote.RemoteWebDriver$ByteBuddy$gPlLDnEY is in unnamed module of loader net.bytebuddy.dynamic.loading.ByteArrayClassLoader @77681ce4; org.openqa.selenium.HasAuthentication is in unnamed module of loader 'app')

How can we reproduce the issue?

How to reproduce the problem:
* Run a selenium grid (standalone / hub&node mode - does not matter)
`java -jar selenium-server.jar standalone --detect-drivers true`
* Execute the code below using selenium-java 4

Code Example
`WebDriver webDriver = RemoteWebDriver
                 .builder()
                 .augmentUsing(new Augmenter())
                 .oneOf(new ChromeOptions())
                 .address(new URL("http://localhost:4444"))
                 .build();
((HasAuthentication) webDriver).register(() -> new UsernameAndPassword("admin", "admin"));
webDriver.get("https://the-internet.herokuapp.com/basic_auth");`

Relevant log output

java.lang.ClassCastException: class org.openqa.selenium.remote.RemoteWebDriver$ByteBuddy$E2NldVid cannot be cast to class org.openqa.selenium.HasAuthentication (org.openqa.selenium.remote.RemoteWebDriver$ByteBuddy$E2NldVid is in unnamed module of loader net.bytebuddy.dynamic.loading.ByteArrayClassLoader @2d38edfd; org.openqa.selenium.HasAuthentication is in unnamed module of loader 'app')

	at com.isobar.commerce.selenium.tests.FeaturesTests.test(FeaturesTests.java:175)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132)
	at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:599)
	at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:174)
	at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
	at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:822)
	at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:147)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at org.testng.TestRunner.privateRun(TestRunner.java:764)
	at org.testng.TestRunner.run(TestRunner.java:585)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
	at org.testng.SuiteRunner.run(SuiteRunner.java:286)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1218)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
	at org.testng.TestNG.runSuites(TestNG.java:1069)
	at org.testng.TestNG.run(TestNG.java:1037)
	at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
	at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)

Operating System

Windows 10 / MacOS BigSur 11.3.1

Selenium version

4.0.0

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

Chrome 94

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

chromedriver 94.0.4606.61

Are you using Selenium Grid?

Yes - 4.0.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
nieperdragoncommented, Dec 2, 2021

Thank you @pujagani I’m currently not able to try this out properly (for many reasons including tightened company restrictions and a dead computer 😦 ). However I appreciate your input and I’ll check out your suggestion when I’m in a position to look at it properly.

1reaction
titusfortnercommented, Oct 20, 2021

Augmentation is only needed for RemoteWebDriver instances because the applicable browser drivers themselves implement the interface. This doesn’t actually address making the second call easier, but with respect to getting an augmented driver in the first place, I wanted to point out that you can use RemoteWebDriverBuilder to automatically augment. Here’s an example:

https://github.com/saucelabs-training/demo-java/blob/docs-1.2/selenium-examples/src/test/java/com/saucedemo/selenium/se4newfeatures/RemoteWebDriverBuilderTest.java

Just thought I’d mention it since there are so few resources out there right now discussing the Augmenter, and it’s super powerful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Selenium Grid showing WebDriverException error
if you are running the Grid, you need to set up Chromedriver executable in the node: java -jar selenium-server-standalone-2.31.0.jar -role node -hub ...
Read more >
What does Selenium 4 have in store for testers? - Abstracta
The Selenium Grid has been rebuilt to include different modes. ... The processes are as follows and in the order they must be...
Read more >
Failed to create browser instance for Selenium Node running ...
When I launch Selenium node and hub manually, there is no such problem with creating ... WebDriverException: unknown error: cannot get automation extension...
Read more >
Is chromedriver binary file not required when running the test ...
I am using selenium grid to run test in chrome browser . when i am using my ... I get an error message...
Read more >
Eclipse java lang NoClassDefFoundError - Selenium - Edureka
And i get the below error: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/config/RegistryBuilder at ...
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