我从表中填写列表时出现问题:
<div class="es">
<button class="btn btn-primary" [routerLink]="['add']">New User</button>
</div>
<div class="User_table" id="t02" >
<div class="table" id="t01" >
<div class="table-row table-header">
<div class="table-row-item"> <span>Number</span><span></span></div>
<div class="table-row-item userimg"></div>
<div class="table-row-item u-flex-grow4"><span>Name</span><span ></span></div>
<div class="table-row-item u-flex-grow4"><span>Rights</span><span ></span></div>
<div class="table-row-item u-flex-grow4"><span>Registered</span><span "></span></div>
<div class="table-row-item u-flex-grow4"><span>Property management</span></div>
</div>
<div *ngFor="let data of User; let i = index" class="table-row">
<div class="table-row-item" data-header="Number">{{i + 1}}</div>
<div class="table-row-item userimg"><img [class]="(data?.image ? '' : 'default')" [src]="data?.img_src" alt= "Profil"/></div>
<div class="table-row-item u-flex-grow4" data-header="Name">{{data?.fName}} {{data?.lName}}</div>
<div class="table-row-item u-flex-grow4" data-header="Rights">{{data?.role}}</div>
<div class="table-row-item u-flex-grow4" data-header="Registered">{{data?.firstTimeLogin | date:'dd.MM.yyyy'}}</div>
<div class="table-row-item u-flex-grow4" data-header="Property management">{{data?.PropertyIds?.length}}<a [routerLink]="['edit', data.id]"><span class="i_edit"></span></a></div>
<!-- routerLink="/Profil/{{ data['id']}}" routerLinkActive="active" [routerLinkActiveOptions]="{exact:true}" -->
</div>
</div>
</div>
我尝试使用Id和Xpath来填充我的列表,但没有任何工作,比如
List<WebElement> TotalRowCount = driver.findElements(By.xpath("//*[@id=\"t01\"]"));
或
List<WebElement> tableRows = driver.findElements(By.className("table-row"));
我正在使用开发人员工具来读取Xpath或其他像cssSelector,但没有任何工作。有什么想法吗?
答案 0 :(得分:0)
如果您尝试使用名称,权利等文字生成 WebElements List
,已注册和物业管理,您可以使用以下代码块:
List<WebElement> TotalRowCount = driver.findElements(By.xpath("//div[@class='table' and @id='t01']//div[@class='table-row-item u-flex-grow4']//following::span[1]"));