-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[grid] Improve SlotMatcher for Node relay to Appium server with hybrid browser and native app #15537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
…d browser and native app Signed-off-by: Viet Nguyen Duc <[email protected]>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the handling of relay sessions for Appium by refining capability matching and filtering logic in both DefaultSlotMatcher and RelaySessionFactory. Key changes include:
- Enhancements to DefaultSlotMatcher to incorporate Appium-specific capabilities.
- Integration of capability filtering in RelaySessionFactory to remove conflicting browserName settings.
- Addition of comprehensive test cases to validate both new matching and filtering behavior, along with an update to the Bazel build configuration for Mockito.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java | Enhanced matching logic for Appium-specific relay capabilities |
java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java | Added filtering logic to remove conflicting browserName settings |
java/test/org/openqa/selenium/grid/node/relay/RelaySessionFactoryTest.java | Added unit tests for capability filtering behavior |
java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java | Added unit tests for new slot matching scenarios |
java/test/org/openqa/selenium/grid/node/relay/BUILD.bazel | Updated build configuration to include the Mockito dependency |
Files not reviewed (1)
- java/test/org/openqa/selenium/grid/node/relay/BUILD.bazel: Language not supported
Comments suppressed due to low confidence (1)
java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java:178
- [nitpick] There are two overloaded methods named 'browserVersionMatch' (one accepting strings and one accepting Capabilities). Consider renaming one of them for better clarity of intent.
private boolean browserVersionMatch(String stereotype, String capabilities) {
PR Code Suggestions ✨Explore these optional code suggestions:
|
CI Feedback 🧐(Feedback updated until commit 22b15db)A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
public static boolean specificRelayCapabilitiesAppMatch(Capabilities capabilities) { | ||
/* | ||
This match is specific for the Relay capabilities that are related to the Appium server for native application. | ||
- If browserName is defined then we always assume it’s a hybrid browser session, so no app-related caps should be provided | ||
- If app is provided then the assumption is that app should be fetched from somewhere first and then installed on the destination device | ||
- If only appPackage is provided for uiautomator2 driver or bundleId for xcuitest then the assumption is we want to automate an app that is already installed on the device under test | ||
- If both (app and appPackage) or (app and bundleId). This will then save some small-time for the driver as by default it tries to autodetect these values anyway by analyzing the fetched package’s manifest | ||
*/ | ||
return SPECIFIC_RELAY_CAPABILITIES_APP.stream() | ||
.anyMatch( | ||
name -> | ||
capabilities.getCapability(name) != null | ||
&& !capabilities.getCapability(name).toString().isEmpty()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how this fixes #14247. Moreover, I don't understand why #14247 is not working.
Maybe #14247 should have not been merged, the user had to configure the stereotypes correctly, and either only send browserName or appium:app in the session capabilities.
I like the refactoring but I don't see how specificRelayCapabilitiesAppMatch
helps or improves the situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diemol, I think it not really fix, also there is no unit test to see the capabilities outcomes looks like.
I spent some time to setup end2end for 3 different scenarios, same as the ticket issue description and their PR describe, none of those work correctly to launch the native app in emulator - https://github.com/NDViet/test-grid-relay-appium/blob/main/reproduce/test_native_app.py
Note that, this browserName
cap set in Node stereotype, which means they expect that Node can take both hybrid browser session and native app.
For example in a scenario, where request capabilities try to unset browserName
, immediately, DefaultSlotMatcher could not match, since browserNameMatch guard the condition as mandatory there.
Signed-off-by: Viet Nguyen Duc <[email protected]>
4079ca3
to
36f83af
Compare
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Motivation and Context
The fix in PR #14247 looks like not work.
In this fix, try to make logic in DefaultSlotMatcher and RelaySessionFactory to be same. Since before coming to RelaySessionFactory.test(), a basic match of W3C caps has already been done (in DefaultSlotMatcher).
Besides unit tests, here is the end2end tests
Relay Node config
This code for native app can be reached 2 slots
And this code for hybrid browser session, which can be reached 1st slot (platformVersion 14), where
browserName
is set in Node stereotype.Types of changes
Checklist
PR Type
Bug fix, Tests
Description
Enhanced
DefaultSlotMatcher
to handle hybrid browser and native app sessions.Added logic to filter conflicting capabilities in
RelaySessionFactory
.Introduced new test cases for relay node matching and capability filtering.
Updated Bazel build configuration to include Mockito dependency.
Changes walkthrough 📝
DefaultSlotMatcher.java
Enhanced SlotMatcher for Appium and hybrid session handling
java/src/org/openqa/selenium/grid/data/DefaultSlotMatcher.java
specificRelayCapabilitiesAppMatch
for Appium-relatedcapabilities.
RelaySessionFactory.java
Added capability filtering in RelaySessionFactory
java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java
filterRelayCapabilities
to handle conflicting capabilities.DefaultSlotMatcherTest.java
Added tests for DefaultSlotMatcher enhancements
java/test/org/openqa/selenium/grid/data/DefaultSlotMatcherTest.java
RelaySessionFactoryTest.java
Added tests for RelaySessionFactory capability filtering
java/test/org/openqa/selenium/grid/node/relay/RelaySessionFactoryTest.java
filterRelayCapabilities
method.BUILD.bazel
Updated Bazel build for Mockito dependency
java/test/org/openqa/selenium/grid/node/relay/BUILD.bazel