I am executing a test with both Selenium 9for the IE/Edge compatibility stuff) and WinAppDriver to handle a Windows file chooser dialog. Regular selenium can't handle Windows features.
I had things working fine a few years ago with an old version of our code. This old project still works. The git repositories have been updated by many users at the company so I cannot change them for my needs. So I made my own project to implement WinAppDriver by setting up and getting the driver (see below). The problem is now when I run the program I get that error message "com.google.common.collect.RegularImmutableMap cannot be cast to org.openqa.selenium.Capabilities". I got this originally in my original project but managed to fix it, I thought by using different versions of selenium-java and appium java-client. However, now not matter what versions I use I get this error. I even tried to make an immutable capabilities to start it, but I get the same error.
Here is some info. part of my pom file:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.5.0</version>
<exclusions>
<exclusion>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</exclusion>
<!-- <exclusion> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId>
</exclusion> -->
</exclusions>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>8.1.1</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
</exclusion>
</exclusions>
</dependency>
I get the driver with the following code:
exec = new HttpCommandExecutor(new URL("http://127.0.0.1:4723/"));
DesiredCapabilities dcaps = new DesiredCapabilities();
dcaps.setCapability("automationName", "Windows");
dcaps.setCapability("app", "Root");
dcaps.setCapability("platformName", "Windows");
dcaps.setCapability("deviceName", "Windows PC");
WindowsDriver app = new WindowsDriver(exec, dcaps);
I had to make my own CommandExecutor because the default one was appending something like appium: to the capabilities, but the WinAppDriver program was not looking for the "appium:". I verified this in the debug window of the WinAppDriver (that you start from Windows or via a java command: Runtime.getRuntime().exec(winAppDriver);
The exception always occurs at java.util.stream.ReferencePipeline$3$1accept (line 193):
@Override
@SuppressWarnings("unchecked")
public final <R> Stream<R> map(Function<? super P_OUT, ? extends R> mapper) {
Objects.requireNonNull(mapper);
return new StatelessOp<P_OUT, R>(this, StreamShape.REFERENCE,
StreamOpFlag.NOT_SORTED | StreamOpFlag.NOT_DISTINCT) {
@Override
Sink<P_OUT> opWrapSink(int flags, Sink<R> sink) {
return new Sink.ChainedReference<P_OUT, R>(sink) {
@Override
public void accept(P_OUT u) {
**downstream.accept(mapper.apply(u));**
}
};
}
};
}
And I have tried many different combinations of selenium-java and java-client, including ones that have worked before. I must have some sort of incompatible maven artifcats but i can't figure out what they are.
Does anyone have an idea or has encountered this?
The WinAppDriver windows application is 1.3 but I do not think that matters in this case because it does not get that far.