Skip to content

[Bug]: text input with number value raises "container is not iterable" with to_match_aria_snapshot #33791

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

Closed
GammaGames opened this issue Nov 27, 2024 · 1 comment · Fixed by #33793
Labels

Comments

@GammaGames
Copy link

Version

1.49.0

Steps to reproduce

  1. Save the below dockerfile
  2. Build and run with docker run $(docker build -q .)
  3. See the error, along with the generated yaml in stdout
FROM mcr.microsoft.com/playwright/python:v1.49.0

RUN pip3 install pytest pytest-playwright

RUN mkdir /test && \
    # create html file
    echo '<!doctype html>' >> /test/index.html && \
    echo '<html>' >> /test/index.html && \
    echo '    <body>' >> /test/index.html && \
    echo '        <input type="text" value="12345"/>' >> /test/index.html && \
    echo '    </body>' >> /test/index.html && \
    echo '</html>' >> /test/index.html && \
    # create python file
    echo 'from playwright.sync_api import Page, expect' >> /test/test_main.py && \
    echo 'def test_main(page: Page):' >> /test/test_main.py && \
    echo '    page.goto("file:///test/index.html")' >> /test/test_main.py && \
    echo '    print(page.locator("body").aria_snapshot())' >> /test/test_main.py && \
    echo '    expect(page.locator("body")).to_match_aria_snapshot("- textbox: 12345")' >> /test/test_main.py

CMD pytest /test --browser chromium --tracing retain-on-failure --output /output -rP

Expected behavior

Yaml should probably be quoted:

- textbox: "12345"

Actual behavior

Yaml is not quoted:

- textbox: 12345

Additional context

Gotta love YAML, it's outputting the text input as a number:

<!doctype html>
<html>
    <body>
        <input type="text" value="12345"/>
    </body>
</html>

If you decide to quote all the things for #33772 this will probably also be fixed

pytest output:

============================= test session starts ==============================
platform linux -- Python 3.12.3, pytest-8.3.3, pluggy-1.5.0
rootdir: /test
plugins: playwright-0.6.2, base-url-2.1.0
collected 1 item

test/test_main.py F                                                      [100%]

=================================== FAILURES ===================================
_____________________________ test_main[chromium] ______________________________

page = <Page url='file:///test/index.html'>

    def test_main(page: Page):
        page.goto("file:///test/index.html")
        print(page.locator("body").aria_snapshot())
>       expect(page.locator("body")).to_match_aria_snapshot("- textbox: 12345")

test/test_main.py:5: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
usr/local/lib/python3.12/dist-packages/playwright/_impl/_locator.py:712: in _expect
    result = await self._frame._channel.send_return_as_dict(
usr/local/lib/python3.12/dist-packages/playwright/_impl/_connection.py:67: in send_return_as_dict
    return await self._connection.wrap_api_call(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <playwright._impl._connection.Connection object at 0x769f283002c0>
cb = <function Channel.send_return_as_dict.<locals>.<lambda> at 0x769f28059a80>
is_internal = False

    async def wrap_api_call(
        self, cb: Callable[[], Any], is_internal: bool = False
    ) -> Any:
        if self._api_zone.get():
            return await cb()
        task = asyncio.current_task(self._loop)
        st: List[inspect.FrameInfo] = getattr(task, "__pw_stack__", inspect.stack())
        parsed_st = _extract_stack_trace_information_from_stack(st, is_internal)
        self._api_zone.set(parsed_st)
        try:
            return await cb()
        except Exception as error:
>           raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
E           playwright._impl._errors.Error: LocatorAssertions.to_match_aria_snapshot: container is not iterable

usr/local/lib/python3.12/dist-packages/playwright/_impl/_connection.py:528: Error
----------------------------- Captured stdout call -----------------------------
- textbox: 12345
============================== 1 failed in 0.96s ===============================

Environment

- Operating System: elementary OS 7.1 (based on Ubuntu 22.04.5 LTS)
- CPU: x86_64
- Browser: Chromium
- Python Version: 3.12
@GammaGames
Copy link
Author

GammaGames commented Nov 27, 2024

Another one: if you have a number next to a checkbox in a table cell it'll generate yaml that throws playwright._impl._errors.Error: LocatorAssertions.to_match_aria_snapshot: value.startsWith is not a function

- gridcell "1":
   - checkbox: on
   - text: 1

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants