Hello Playwright experts,
I have this input field
<input id="myName" placeholder="e.g. Max" maxlength="15" />
I have tried this JAVA code:
page.locator("[placeholder=\"e.g. Max\"]").textContent();
It does not work :-( but I can fill
page.locator("[placeholder=\"e.g. Max\"]").fill("Loren"); // this works
Could you help and has an idea?
Thank you in advance.
Cheers Loren
CodePudding user response:
textContext
won't return a value of an input. The same will happen if you try that in the DevTools.
You can use inputValue instead.
e.g.
page.locator("#myName").inputValue();
CodePudding user response:
In case you want to assert your value you can use the .hasValue
assertion. You can read more about it from the playwright docs.
assertThat(page.locator("#myName")).hasValue("input-value");