[Feature] page.getAttribute('value') confuses people
See original GitHub issueSituation:
For users who are migrating from Selenium over to Playwright it might be confusing that we handle the element attributes in the getAttribute()
method strictly and returning by that only element attributes. For them it might be logical that it returns properties too. I agree on that.
Selenium: Selenium solves this by trying to get the property first and using the attributes as a fallback, see here:
Possible solutions:
Since Pavel proposed to not modify the getAttribute()
method since it would then work differently what the name says, I would maybe add a helper function to it. Usage could look like as follows:
page.getElementValue("#foo", "value") // not sure about a better function name
Example See the following example which works on Selenium but not on Playwright once you migrate over to Playwright: https://try.playwright.tech/?s=27y84
Issue Analytics
- State:
- Created 3 years ago
- Reactions:11
- Comments:10 (5 by maintainers)
Top GitHub Comments
Let’s see how many users will face into that issue and then add the suggested feature like a warning and a inputValue() function e.g.
For those needing an example of how to do this, check this updated sandbox:
https://try.playwright.tech/?s=t5tfy46