我正在为我的 SpringBoot 应用程序开发一个 selenium 测试,我已经成功地创建了一个新帐户,在该帐户上创建了一个新项目并将其值设置为 funds=0,然后我向该项目捐款,并重定向到页面它显示了一个用户的贡献,包括 'amountContributed' 元素,其值 > 0 作为捐赠。
如何在 Selenium 测试中检查元素的值?我的尝试在下面,我得到的错误在下面:
//重定向到用户贡献页面。assertEquals("你的贡献", this.webDriver.getTitle());
//Assert that the total contributed amount for the project is 2000 as it was 0 prior to contribution.
assertEquals("2000", this.webDriver.findElement(By.id("amountContributed")));
expected: <2000> but was: <[[ChromeDriver: chrome on WINDOWS (60e2cb3895ae1f8e300b2068bd0f46c7)] -> id: amountContributed]>
HTML:
<span>Amount Contributed: </span>
<li th:text="${project.amountContributed}" id="amountContributed">Amount Contributed</li>