This error message…
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
at org.openqa.selenium.firefox.FirefoxDriver
…implies that the file com/google/common/collect/ImmutableMap
might be corrupted or there is some incompatibility between the version of the binaries you are using specifically with the guava version / dependency (maven).
You need to take care of a couple of things as follows:
-
In the
System.setProperty()
line you need to changewebdriver.firefox.marionette
towebdriver.gecko.driver
. So effectively, the line of code will be:System.setProperty("webdriver.gecko.driver","C:\\Program Files\\Java\\jre1.8.0_231\\lib\\ext\\geckodriver.exe");
-
Incase you are using maven deleting the corrup/incompatible
.m2
folder can solve your issue. -
Upgrade JDK to recent levels JDK 8u222.
-
Upgrade Selenium to current levels Version 3.141.59.
-
Upgrade GeckoDriver to GeckoDriver v0.26.0 level.
-
GeckoDriver is present in the desired location.
-
GeckoDriver is having executable permission for non-root users.
-
Upgrade Firefox version to Firefox v70.0 levels.
-
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
-
(WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
-
(LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
-
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
-
Take a System Reboot.
-
Execute your
Test
as a non-root user. -
Always invoke
driver.quit()
withintearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.
Reference
You can find a relevant discussion in: