代码之家  ›  专栏  ›  技术社区  ›  Devleena

如何获取行号,以便行在量角器中包含特定文本

  •  0
  • Devleena  · 技术社区  · 6 年前

    <tr class="K7hAcc QwxBBf" for="iBW8sb0" jsshadow="">
      <td class="XgRaPc AB6Eee RdU54d IRKtVe PLK3Id hhyjHe">
        <content class="zRhise">
          <a class="GRgXff sV" href="https://business.google.com/dashboard/l/16047977676197040292">
            <span class="j5emz">Cavender's Boot City</span><br>
            <span class="D0EYxd">303 NW Loop 410, San Antonio, TX 78216, United States</span>
          </a></content></td>
      <td class="XgRaPc AB6Eee RdU54d IRKtVe">
        <content class="zRhise"><svg viewBox="0 0 24 24" class="zQoJdc P6t5mb"><path d="M0 0h24v24H0z" fill="none"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"></path></svg>
          <span class="StcyZc">Published</span>
        </content></td>
      <td class="XgRaPc AB6Eee RdU54d IRKtVe">
        <content class="zRhise"><div class="ypExpf"></div>
        </content></td>
    </tr>
    

    2 回复  |  直到 6 年前
        1
  •  0
  •   Madhan Raj    6 年前
    <ul>
      <li class="pet">Dog</li>
      <li class="pet">Cat</li>
    </ul>
    Code
    // Returns the li for the dog, but not cat.
    var dog = element(by.cssContainingText('.pet', 'Dog'));
    

    请参阅上述代码。确保您有正确的CSS并替换 Dog

        2
  •  0
  •   technodeath    6 年前

    在这种情况下,可以使用XPath,例如:

    var yourvariable = element(by.xpath('//span[text()="Published"]/ancestor::td'));
    

    另外,这不是CSS代码,而是HTML