feat: add directConnect feature by KazuCocoa · Pull Request #1747 · appium/java-client
Change list
I'd like to add https://appiumpro.com/editions/86-connecting-directly-to-appium-hosts-in-distributed-environments for Java client. Other clients such as webdriverio, Ruby and Python already have them for long. If the response had directConnect capabilities, the appium client attempt to send requests to the directConnect one instead of the original URL.
- directConnectProtocol
- directConnectHost
- directConnectPort
- directConnectPath
or appium: prefixed ones.
Types of changes
What types of changes are you proposing/introducing to Java client?
Put an x in the boxes that apply
- No changes in production code.
- Bugfix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
Details
The main change is setDirectConnect in src/main/java/io/appium/java_client/remote/AppiumCommandExecutor.java
To allow users to turn it on/off, I've added AppiumClientConfig and give the instance to the driver.
The example code is like...
* AppiumClientConfig clientConfig = AppiumClientConfig.defaultConfig()
* .baseUri(URI.create("WebDriver URL"))
* .readTimeout(Duration.ofMinutes(5));
* WindowsOptions options = new WindowsOptions();
* WindowsDriver driver = new WindowsDriver(clientConfig, options);
By inheriting ClientConfig, we can set a custom User Agent as well. This PR includes the way to set the UA like appium/8.3.0 (selenium/4.5.0 (java mac))
The naming and implementation methods in AppiumClientConfig follow ClientConfig as possible.
ImeHandler removal in the test code was selenium 4.5.0 removed it.