您好剧作家专家,
我有这个输入框
<input id="myName" placeholder="e.g. Max" maxlength="15" class="xyz"/>
我试过这个 JAVA 代码:
page.locator("[placeholder=\"e.g. Max\"]").textContent();
它不起作用 :-( 但我可以填写
page.locator("[placeholder=\"e.g. Max\"]").fill("Loren"); // this works
你能帮忙并有想法吗?
提前谢谢你。
干杯 洛伦
最佳答案
textContext
不会返回输入值。如果您在 DevTools 中尝试这样做,也会发生同样的情况。
您可以使用 inputValue相反。
例如
page.locator("#myName").inputValue();
关于java - 编剧JAVA : How to get the VALUE of an input field,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72803360/