appium / java-client

Java language binding for writing Appium Tests, conforms to W3C WebDriver Protocol
Apache License 2.0
1.2k stars 755 forks source link

[Feat]: Isolate macOS value in enum Platform for Chromium Driver #1990

Closed AlessandroMiccoli closed 12 months ago

AlessandroMiccoli commented 1 year ago

ERROR: I need to run an automation test on the Chrome browser, and I created a class that extends BaseOptions. When I set the platform name, I could use only macOS, Windows or Linux. When I use macOS, it is converted to mac.

This is the error:

org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: An unknown server-side error occurred while processing the command. Original error: Could not find a driver for automationName 'Chromium' and platformName '**mac**'. Have you installed a driver that supports those capabilities? Run 'appium driver list --installed' to see. (Lower-level error: Driver 'chromium' supports automationName 'Chromium', but Appium could not find support for platformName 'mac'. Supported platformNames are: ["Windows","macOS","Linux"])

If I understood correctly, the reason lies in the Platform enum class: MAC("mac", "darwin", "macOS", "mac os x", "os x")

TEMPORARY SOLUTION: At the moment, I bypassed the issue, giving "Linux" values as the platform name.

REQUEST Is it possible to isolate the macOS value in the enum Platform? Or is there an alternative solution for using macOS?

mykola-mokhnach commented 1 year ago

Are you sure the code responsible for that is not in the selenium lib?

AlessandroMiccoli commented 1 year ago

The Platform enum is in selenium. You are right. Appium inherits the issue. And systematically here I have the conversion from macOS to mac:

    @Override
    @Nullable
    public Platform getPlatformName() {
        return Optional.ofNullable(getCapability(CapabilityType.PLATFORM_NAME))
                .map(cap -> {
                    if (cap instanceof Platform) {
                        return (Platform) cap;
                    }

                    try {
                        return Platform.fromString((String.valueOf(cap)));
                    } catch (WebDriverException e) {
                        return null;
                    }
                })
                .orElse(null);
    }

Do I need to make the request in the Selenium GitHub? Or could we fix it in Appium?

mykola-mokhnach commented 1 year ago

We are patching many things in Appium although this particular change could be breaking. Is there a possibility for you to do the necessary patching in your code?

AlessandroMiccoli commented 1 year ago

Yes, I could try to make the changes.

AlessandroMiccoli commented 1 year ago

Probably, a solution could be to include or amend the macOS value in appium-chromium-driver?

  "appium": {
    "driverName": "chromium",
    "automationName": "Chromium",
    "platformNames": [
      "Windows",
      "macOS",
      "Linux"
    ],
    "mainClass": "ChromiumDriver"
  },
mykola-mokhnach commented 1 year ago

yes, this might be possible. Maybe another simple PR from you? ;)

jlipps commented 1 year ago

We would definitely merge a simple PR that added a compatible platformName to the chromium driver's manifest.

AlessandroMiccoli commented 12 months ago

I created the pull request for fixing the issue: https://github.com/appium/appium-chromium-driver/pull/158

It should fix the issue.

I am curious to learn more about the current implementations of the libraries linked to appium if someone is interested in spending time with me. Let me know if you have a group; if it is open, I will be happy to participate.

mykola-mokhnach commented 12 months ago

We use Slack for internal dev-related communication. Feel free to join it.

AlessandroMiccoli commented 12 months ago

This issue could be closed. I updated the driver to chromium@1.2.0, and now it works.

Capabilities {appium:automationName: CHROMIUM, browserName: CHROME, platformName: MAC}

@mykola-mokhnach Thanks for merging my PR so quickly.

AlessandroMiccoli commented 11 months ago

@mykola-mokhnach The slack link doesn't work. Could you give me directions for joining the group?

Dor-bl commented 11 months ago

Try this link : https://join.slack.com/t/appium/shared_invite/zt-23r2uxltf-BtEghonAa~GmH4XeN9CIhA