Skip to content
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

[🐛 Bug]: Cannot start mobile application with appium when slot also specifies a 'browserName' capability #14216

Closed
bhecquet opened this issue Jul 1, 2024 · 7 comments · Fixed by #14247

Comments

@bhecquet
Copy link
Contributor

bhecquet commented Jul 1, 2024

What happened?

Hello,

I've set up a selenium grid with an appium server which is linked to grid through relay feature

the android device stereotype is:

{
"stereotype": {
              "appium:deviceName": "sdk_gphone64_x86_64",
              "appium:platformVersion": "14",
              "browserName": "chrome",
              "platformName": "ANDROID",
            }
}

When I want to test a mobile application, I provide the following capabilities

{
    "platformName": "ANDROID",
    "appium:appActivity": "com.company.AuthenticationActivity",
    "appium:chromedriverExecutable": "D:/drivers/chromedriver_113.0_chrome-113-114.exe",
    "appium:fullReset": true,
    "appium:automationName": "UIAutomator2",
    "appium:deviceName": "sdk_gphone64_x86_64",
    "appium:newCommandTimeout": 120,
    "appium:platformVersion": "14",
    "appium:app": "http://127.0.0.1:44454/app_2024_06_27.apk",
    "appium:udid": "emulator-5554"
}

But, the received capabilities on appium side are:

{
    "platformName": "ANDROID",
    "browserName": "chrome",
    "appium:appActivity": "com.company.AuthenticationActivity",
    "appium:chromedriverExecutable": "D:/drivers/chromedriver_113.0_chrome-113-114.exe",
    "appium:fullReset": true,
    "appium:automationName": "UIAutomator2",
    "appium:deviceName": "sdk_gphone64_x86_64",
    "appium:newCommandTimeout": 120,
    "appium:platformVersion": "14",
    "appium:app": "http://127.0.0.1:44454/app_2024_06_27.apk",
    "appium:udid": "emulator-5554"
}

This is due to

capabilities = capabilities.merge(stereotype);

which merges stereotypes from slot (where 'browserName' is present) and requested capabilities (where 'appium:app' is present)
According to UIAutomator2 driver, Do not provide both app and browserName capabilities at once.

This change has been introduced with this commit: 0013140

I think one of the solution would be to make de "merge" operation more precise (e.g: not adding browserName if appium:app is provided). This would add some specific code whereas relay session is generic, but it's a common use case
If you have any other idea, I would be glad to implement a correction

Bertrand

How can we reproduce the issue?

See details above

Relevant log output

Appium logs:

2024-07-01 07:52:05:854 �[38;5;-154m[AndroidUiautomator2Driver@5a4c] Creating session with W3C capabilities: {
  "alwaysMatch": {
    "browserName": "chrome",
    "goog:chromeOptions": {},
    "platformName": "ANDROID",
    "appium:appActivity": "com.company.AuthenticationActivity",
    "appium:chromedriverExecutable": "D:/drivers/chromedriver_113.0_chrome-113-114.exe",
    "appium:fullReset": true,
    "appium:automationName": "UIAutomator2",
    "appium:deviceName": "sdk_gphone64_x86_64",
    "appium:newCommandTimeout": 120,
    "appium:platformVersion": "14",
    "appium:app": "http://10.200.71.24:44454/grid/admin/FileServlet?file=file:upload/app/d40777c0-c046-4dc0-8cc6-f7b419cfd3b6/app_2024_06_27.apk",
    "appium:udid": "emulator-5554"
  },
  "firstMatch": [
    {}
  ]
}
2024-07-01 07:52:05:862 �[38;5;-154m[AndroidUiautomator2Driver@5a4c] The following provided capabilities were not recognized by this driver:
2024-07-01 07:52:05:863 �[38;5;-154m[AndroidUiautomator2Driver@5a4c]   goog:chromeOptions
2024-07-01 07:52:05:864 �[38;5;-154m[AndroidUiautomator2Driver@5a4c] The desired capabilities should generally not include both an 'app' and a 'browserName'

Operating System

Any

Selenium version

4.18.1

What are the browser(s) and version(s) where you see this issue?

Chrome / not related to browser

What are the browser driver(s) and version(s) where you see this issue?

not related to browser

Are you using Selenium Grid?

4.18.1

Copy link

github-actions bot commented Jul 1, 2024

@bhecquet, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol
Copy link
Member

diemol commented Jul 1, 2024

Good catch. Would you like to send a PR to fix this?

@bhecquet
Copy link
Contributor Author

bhecquet commented Jul 1, 2024

Yes sûre
If you agree, I will just remove browserName cap in case appium:app is present, hoping there is no other incompatibility

@diemol
Copy link
Member

diemol commented Jul 2, 2024

That approach sounds good.

@krishtoautomate
Copy link

this can fix this issue too:

boolean browserNameMatch = (stereotype.getBrowserName() == null || stereotype.getBrowserName().isEmpty() || capabilities.getBrowserName() == null || capabilities.getBrowserName().isEmpty()) || Objects.equals(stereotype.getBrowserName(), capabilities.getBrowserName()); boolean browserVersionMatch = (stereotype.getBrowserVersion() == null || stereotype.getBrowserVersion().isEmpty() || capabilities.getBrowserVersion() == null || capabilities.getBrowserVersion().isEmpty()) || Objects.equals(stereotype.getBrowserVersion(), capabilities.getBrowserVersion());

@bhecquet
Copy link
Contributor Author

bhecquet commented Jul 8, 2024

@krishtoautomate , I don't thinks so, as you suggest a change in Matcher whereas matching is correctly done on my side (I've not checked if it's due to my custom matcher or not).
Problem is on session creation, after matching

I've written a correction that I need to verify before creating the PR

Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants