【问题标题】:how to click element with _ngcontent and span buttontext using Protractor typescript如何使用量角器打字稿单击带有_ngcontent和跨度按钮文本的元素
【发布时间】:2019-04-30 09:10:18
【问题描述】:

我需要有关创建量角器打字稿代码的帮助,如何单击此按钮?它有 _ngcontent 和 span 按钮文本,有人知道怎么做吗?网站上的代码是:

 <span _ngcontent-c6  class="braeting net-subheading-2"> ... </span>
 <button _ngcontent-c6  class="tulbar-button net-button" net-button>
   <span class="net-button-wrapper">
      <span _ngcontent-c6="">Login</span>
   </span>
  <div class="net-button-ripple net-ripple" matripple></div>
 <div class="net-button-focus-overlay"></div>
 </button>

我尝试了以下方法,我似乎无法使其工作..

clickSignin = element(by.cssContainingText('tulbar-button net-button','Login'));
clickSignin = element(by.xpath('//span[@class="tulbar-button net-button"][_ngcontent-c6="Login"]'));
clickSignin = element(by.xpath('//span[@class="tulbar-button net-button"][text()="Login"]'));

然后执行

clickSignin.click();

它们似乎都不起作用..并且错误说: 失败:使用定位器找不到元素:By(xpath..... or by.cssContainingText....

【问题讨论】:

    标签: angular typescript jasmine protractor


    【解决方案1】:

    试试这个:

    注意:你对 cssContainingText 的论证是错误的

    clickSignin = element(by.cssContainingText('.tulbar-button.net-button','Login'));
    

    【讨论】:

      猜你喜欢
      • 2019-05-19
      • 2019-12-22
      • 2020-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多