【发布时间】:2020-06-12 23:41:22
【问题描述】:
我正在尝试验证页面上的一些内容,并有一个带有标题列的网格。我想从中获取文本是验证的一部分。出于某种原因,它返回为空,我不明白为什么考虑到我使用包含文本来查找元素。
String expectedName = "Employee Name";
String actualName = driver.findElement(By.xpath("//div[contains(text(), 'Employee Name')]")).getText();
Assert.assertEquals(expectedName, actualName);
我得到的错误是:java.lang.AssertionError: expected [Employee Name] but found []
HTML:
<div class="dx-datagrid-text-content dx-text-content-alignment-left dx-header-filter-indicator" role="presentation">Employee Name</div>
【问题讨论】:
标签: java html selenium selenium-webdriver