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]:Issue with get_attribute method #33724

Closed
Abinayadevi16 opened this issue Nov 22, 2024 · 3 comments
Closed

[Bug]:Issue with get_attribute method #33724

Abinayadevi16 opened this issue Nov 22, 2024 · 3 comments

Comments

@Abinayadevi16
Copy link

Version

1.46.0

Steps to reproduce

There is an existing value in textbox we are trying retrieve the value from the textbox using getattribute method its retrieving properly
but we are clearing the textbox and adding a new value and trying to use getattribute method to get the value . It still provides the old value which was existing in the textbox and not the new value

Expected behavior

New value to be retrieved

Actual behavior

old value is retrieved

Additional context

No response

Environment

version 1.46.0
@dgozman
Copy link
Contributor

dgozman commented Nov 22, 2024

@Abinayadevi16 You should use locator.evaluate instead, because attribute does not change when you are editing the textbox.

locator = page.get_by_role("textbox")
# ...
value = locator.evaluate("e => e.value")

Let me know whether this helps.

@mxschmitt
Copy link
Member

Closing as per above. We also have the inputValue() method for it.

https://playwright.dev/python/docs/api/class-locator#locator-input-value

@Abinayadevi16
Copy link
Author

Hi @dgozman , thanks it worked. @mxschmitt Thanks for the suggestion

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

No branches or pull requests

3 participants