-
Notifications
You must be signed in to change notification settings - Fork 5k
Description
Situation:
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 nameExample
See the following example which works on Selenium but not on Playwright once you migrate over to Playwright: https://try.playwright.tech/?s=27y84