Skip to content

🐞 bug:[docs][python-client][images] Mismatch: docs expect string, parameter type is bytes AppiumBy.IMAGE / get_images_similarity #1169

@wooyoung294

Description

@wooyoung294

Is there an existing issue for this?

  • I have searched the existing issues

Appium Version

2.19.0

Appium Host Type

Command Line

Are you using Appium components not maintained by the Appium team?

No response

Is this issue reproducible using the latest components?

  • I confirm the issue is still reproducible with the latest component versions

Current Behavior

Environment
python: 3.9
appium-python-client : 5.2.2

Expected
(docs): image selector/params should be a base64-encoded string.

Actual
(Python client): parameter type is bytes

Image

Expected Behavior

If this issue is valid, I’d like to submit a PR with the following change to align the parameter type with the docs (string) while still accepting bytes:

def get_images_similarity(
    self,
    base64_image1: Union[str, bytes],
    base64_image2: Union[str, bytes],
    **opts: Any
) -> Dict[str, Any]:
    ...

Appium Log

No response

Environment Details

  • Debug details (appium --show-debug-info):
  • Last component version(s) which did not exhibit the problem:
  • Platform and version of device under test:
  • Real device or emulator/simulator:

Minimal Reproducible Example

from PIL import Image
from appium.webdriver.webdriver import WebDriver
def compare_image_similarity(driver:WebDriver, path, target):
    with Image.open(path) as im:
        buf = io.BytesIO()
        im.save(buf, format="PNG")
        original_png = buf.getvalue()

    target_png = target.screenshot_as_png

    original_png_b64 = base64.b64encode(original_png).decode("ascii")
    target_png_b64 = base64.b64encode(target_png).decode("ascii")

    driver.get_images_similarity(original_png_b64, target_png_b64, visualize=True)

Further Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions