量角器自动化按钮在“_ngcontent-c6”内单击
Protractor automation button click inside '_ngcontent-c6'
我的应用程序有一个按钮,带有 _ngcontent-c6
,我无法点击它。
element(by.css("button[class*='primary-btn']")).click()
正在定位按钮 -span >class="ng-star-inserted" 的父项。
留言:
Failed: No element found using locator: By(css selector, button[class*='primary-btn'])
<b>
<span _ngcontent-c6="" title="" class="ng-star-inserted">
<button _ngcontent-c6="" class="button primary-btn">
Create New Request
</button>
</span>
</b>
通过 xpath
尝试定位器:
element(by.xpath("//*[@class='button primary-btn' and contains(text(),'Create New Request')]")).click()
element(by.buttonText("Create New Request"))
或
element(by.css(".button.primary-btn"))
如果上面提供的 none 解决方案不起作用(@Sameer 和@Frian 或我的 xpath),请确保等到您的按钮使用 Protractor Expected Conditions
进行交互
您也可以尝试使用以下代码片段。
element(by.xpath("//span[@class='ng-star-inserted']//child::button[@class='button
primary-btn']").click();
我的应用程序有一个按钮,带有 _ngcontent-c6
,我无法点击它。
element(by.css("button[class*='primary-btn']")).click()
正在定位按钮 -span >class="ng-star-inserted" 的父项。
留言:
Failed: No element found using locator: By(css selector, button[class*='primary-btn'])
<b>
<span _ngcontent-c6="" title="" class="ng-star-inserted">
<button _ngcontent-c6="" class="button primary-btn">
Create New Request
</button>
</span>
</b>
通过 xpath
尝试定位器:
element(by.xpath("//*[@class='button primary-btn' and contains(text(),'Create New Request')]")).click()
element(by.buttonText("Create New Request"))
或
element(by.css(".button.primary-btn"))
如果上面提供的 none 解决方案不起作用(@Sameer 和@Frian 或我的 xpath),请确保等到您的按钮使用 Protractor Expected Conditions
进行交互您也可以尝试使用以下代码片段。
element(by.xpath("//span[@class='ng-star-inserted']//child::button[@class='button
primary-btn']").click();