不太确定如何在不使用nth-child的情况下使用Geb查找定位器

问题描述 投票:0回答:1

我必须根据我的同事的建议找到一个更好的定位器,因为他们不希望我使用第n个子定位器,这会使我的测试更加脆弱。我真的很努力尝试编写这个特定的定位器来访问下面的动态内容代码。

我尝试了以下操作:

flipperCardOne(wait: true, waitCondition: {
    it.displayed
}) {
    $(class: "h3", class: "info-card-name", text: "Mandy Smith)
}
and flipperCardOne(wait: true, waitCondition: {
    it.displayed
}) {
    $(class: "flex-item.front > .w-100", text: "Mandy Smith")
}

但是不太正确。

<div _ngcontent-vho-c20="" class="flex-item">
   <!---->
   <u-flippy-card _ngcontent-vho-c20="" _nghost-vho-c24="" flipped="false">
      <!---->
      <div _ngcontent-vho-c24="" class="flipper">
         <div _ngcontent-vho-c24="" class="front w-100"><img _ngcontent-vho-c24="" class="w-100" src="assets/images/life/mandy_smith.jpg"></div>
         <div _ngcontent-vho-c24="" class="back w-100 info-card">
            <p _ngcontent-vho-c24="" class="info-card-quote”>”TESTING.”</p><h4 _ngcontent-vho-c24="" class="info-card-name">Mandy Smith
            </h4>
         </div>
      </div>
   </u-flippy-card>
</div>
geb
1个回答
0
投票

我注意到您在标记为h4时正在寻找h3。

如果文本“ Mandy Smith”是一个常量,则只需按文本值定位:

{ $('h4').find(text: 'Mandy Smith') }
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.