java-client
java-client copied to clipboard
Issue with AppiumLocalDriverService when repo has dependencies on both Appium and Selenium 4
Description
Given the dependency on both selenium 4 and appium, when I try to build a DriverService object for AppiumDriver, the operation fails with the below exception :
java.lang.AbstractMethodError: Receiver class io.appium.java_client.service.local.AppiumServiceBuilder does not define or inherit an implementation of the resolved method abstract createArgs()Ljava/util/List; of abstract class org.openqa.selenium.remote.service.DriverService$Builder.
Environment
- Java client build version or git revision if you use some snapshot:
io.appium:java-client:7.3.0 - Appium server version or git revision if you use some snapshot: NA
- Desktop OS/version used to run Appium if necessary: NA
- Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: NA
- Mobile platform/version under test: NA
- Real device or emulator/simulator: NA
Details
Noticed that this issue is occurring due to a conflict of Selenium 4 and Appium. The abstract Builder class has now an extra argument for duration. The same code works fine when I downgrade the selenium version to 3.141.59
Code To Reproduce Issue [ Good To Have ]
In the build.gradle file :
dependencies {
api 'io.appium:java-client:7.3.0',
api 'org.seleniumhq.selenium:selenium-java:4.0.0-alpha-6'
}
public static void main(String[] args) {
AppiumDriverLocalService iOSDriverService;
String appiumDriverPath = "/usr/local/bin/appium";
String nodeJSDriverPath = "/usr/local/bin/node";
iOSDriverService = new AppiumServiceBuilder()
.usingDriverExecutable(new File(nodeJSDriverPath))
.withAppiumJS(new File(appiumDriverPath))
.withIPAddress("0.0.0.0")
.usingAnyFreePort()
.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
.withArgument(GeneralServerFlag.LOG_LEVEL,"error")
.build();
iOSDriverService.start();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"iOS");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,"13.2");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"iPhone 11 Pro Max");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME,"XCUITest");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME,"Safari");
AppiumDriver<MobileElement> ios = new IOSDriver<>(iOSDriverService, capabilities);
ios.get("https://www.google.com");
}
Exception Stacktraces
https://gist.github.com/rookieInTraining/4c43f3888f3e088d8ae78195a0a4f641
Link To Appium Logs
NA
The error is expected. java client is not compatible to selenium4
@mykola-mokhnach - Do we have plans to update the java-client with the given code changes?
no plans until there is a stable release
ok, got it.
@mykola-mokhnach getting the same error,
Exception in thread "main" java.lang.AbstractMethodError: Receiver class io.appium.java_client.service.local.AppiumServiceBuilder does not define or inherit an implementation of the resolved method 'abstract java.util.List createArgs()' of abstract class org.openqa.selenium.remote.service.DriverService$Builder. at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:441) at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:91)
Appium Server: v2.0.0-beta.18 Selenium: 4 java-client: 7.6.0
I am using below code:
AppiumDriverLocalService service = AppiumDriverLocalService.buildService( new AppiumServiceBuilder().usingPort(getPort()).withLogFile(new File(System.getProperty("user.dir") + "\\Logs\\Appium_logs\\appiumLogs_" + getCurrentDateAndTime() + ".txt"))); service.start();
Code for getPort():
private static int getPort() throws Exception { int port = 0; try { ServerSocket socket = new ServerSocket(0); socket.setReuseAddress(true); port = socket.getLocalPort(); socket.close(); } catch (Exception e) { e.printStackTrace(); } return port; }
java-client: 7.6.0
Selenium 4 is supported starting from 8.0.0-beta version.
Hi! i have the same problem using maven. Any one can give me a tip to how to solve it? thanks!
The error is expected. java client is not compatible to selenium4
any solution yet?
@mykola-mokhnach getting the same error,
Exception in thread "main" java.lang.AbstractMethodError: Receiver class io.appium.java_client.service.local.AppiumServiceBuilder does not define or inherit an implementation of the resolved method 'abstract java.util.List createArgs()' of abstract class org.openqa.selenium.remote.service.DriverService$Builder. at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:441) at io.appium.java_client.service.local.AppiumDriverLocalService.buildService(AppiumDriverLocalService.java:91)
Appium Server: v2.0.0-beta.18 Selenium: 4 java-client: 7.6.0
I am using below code:
AppiumDriverLocalService service = AppiumDriverLocalService.buildService( new AppiumServiceBuilder().usingPort(getPort()).withLogFile(new File(System.getProperty("user.dir") + "\\Logs\\Appium_logs\\appiumLogs_" + getCurrentDateAndTime() + ".txt"))); service.start();Code for getPort():
private static int getPort() throws Exception { int port = 0; try { ServerSocket socket = new ServerSocket(0); socket.setReuseAddress(true); port = socket.getLocalPort(); socket.close(); } catch (Exception e) { e.printStackTrace(); } return port; }
@sanoj-s how this issue has been resolved?