Angular 10 个应用程序的 XPATH 查询

XPATH Query for Angular 10 Application

我已经使用 Angular 10 为前端构建了一个简单的 Web 应用程序。现在我正在使用 pytest 和 Selenium 网络驱动程序编写测试脚本。我无法找到可靠的 XPATH 来检查我的网络应用程序 'Star' 页面上是否存在文本。下面包含的是应用程序外观的图片。

测试相对简单:导航至 'Star' 页面并检查 table 中是否存在特定恒星(即 Sol)。而已。但是,我似乎找不到文本的有效 XPATH。我一直在开发人员工具中尝试不同的 XPATH 查询,但是 none 它们都可以工作……任何事情。按钮、文字等

我还包含了相关页面的 HTML 代码:show-star.component.html

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary float-right m-2" 
data-bs-toggle="modal" data-bs-target="#exampleModal"
(click)="addClick()"
data-backdrop="static" data-keyboard="false"
>
    Add Star
  </button>
  
  <!-- Modal -->
  <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-xl">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">{{ModalTitle}}</h5>
          <button type="button" class="btn-close" 
          data-bs-dismiss="modal" aria-label="Close"
          (click)="closeClick()" >
        </button>
        </div>
        <div class="modal-body">
            <app-add-edit-star [star]="star" *ngIf="ActivateAddEditStarComp"> 
            </app-add-edit-star>
        </div>
      </div>
    </div>
  </div>

<table class="table table-striped">
    <thead>
        <tr>
            <th>Star ID</th>
            <th>Star Name</th>
            <th>Options</th>
        </tr> 
    </thead>
    <tbody>
        <tr *ngFor="let dataItem of StarList">
            <td>{{dataItem.StarID}}</td>
            <td>{{dataItem.StarName}}</td>
            <td>
                <button type="button" class="btn btn-light mr-1"
                data-bs-toggle="modal" data-bs-target="#exampleModal"
                (click)="editClick(dataItem)"
                data-backdrop="static" data-keyboard="false">
                    Edit
                </button>
                <button type="button" class="btn btn-light mr-1"
                (click)="deleteClick(dataItem)">
                    Delete
                </button>
            </td>
        </tr>
    </tbody>
</table>

我认为它会像 //div[contains(text(),'Sol')] 这样简单,但似乎没有任何效果。 我到底做错了什么?

编辑 1: XPATH //td[contains(text(),'Sol')] 与 Dev Tools

中的任何选择器都不匹配

编辑 2: 这是 Dev Tools 中的代码片段

你确定它包裹在 div 中吗?

"//td[contains(text(),'Sol')]"