-2
我有一个场景,我需要从文本框中获取特定文本。我明白下面的代码将返回文本框中的整个文本。有没有办法从文本框中获取特定的文本行,而不是整个文本?谢谢!如何从文本框中获取特定文本
WebElement config = driver.findElement(By.id("adFragment"));
//Assertion
verifyDisplay(config.getAttribute("value"), By.id("adFragment"));
的HTML:
<section style="display: block;">
<div>
<h2 class="no-margin">tag source</h2>
<div>
<textarea placeholder="Your HTML fragment here" rows="30" id="adFragment" name="adFragment" style="height:400px; width:800px;"></textarea><br>
</div>
</div>
</section>
'getAttribute'将返回文本框中的整个文本...你能解释一下你需要从文本框中得到什么。 – Programmer
@编程器,我需要获取一个动态变化的url链接作为一个字符串... – familyGuy
你的问题还不清楚。请阅读此https://stackoverflow.com/help/mcve并相应地进行调整。 – SiKing