跨度内的硒黄瓜文本

时间:2017-11-30 19:18:52

标签: ruby selenium cucumber

 <div class="tabs-container">
    <div class="wizard-tab active-tab">
  <a class="tab-link-1" href="#">
    <div class="number-circle">1</div>
     <span class="tab-text">Personal Info</span>
</a>  <div class="active-arrow"></div>
</div>

    <div class="wizard-tab inactive-tab">
  <a class="tab-link-2" href="#">
    <div class="number-circle">2</div>
    <span class="tab-text">Address</span>
</a>  <div class="active-arrow"></div>
</div>

    <div class="wizard-tab inactive-tab">
  <a class="tab-link-3" href="#">
    <div class="number-circle">3</div>
    <span class="tab-text">Identity</span>
</a>  <div class="active-arrow"></div>
</div>

    <div class="wizard-tab inactive-tab">
  <a class="tab-link-4" href="#">
    <div class="number-circle">4</div>
    <span class="tab-text">Consent</span>
</a>  <div class="active-arrow"></div>
</div>

  </div>

我想选择或检查跨度中的文本,对于我成功使用的第一个文本:

Then element having css "span.tab-text" should have text as "Personal Info"

现在我想为所有标签做这件事,谢谢。

2 个答案:

答案 0 :(得分:0)

我这样做了,并且有效:

Then element having css "div.tabs-container div.active-tab span.tab-text" should have text as "Personal Info"

答案 1 :(得分:0)

从&lt; a &gt;的class属性开始标签。

   Then element having css "a[class$='link-1']>div>span" should have text as "Personal Info"
   Then element having css "a[class$='link-2']>div>span" should have text as "Address"
   Then element having css "a[class$='link-3']>div>span" should have text as "Identity"
   Then element having css "a[class$='link-4']>div>span" should have text as "Consent"