简体   繁体   English

获取带有一些文本的按钮,然后单击量角器不起作用,为什么?

[英]Get a button with some text and click with protractor doesn't work, why?

I have a button with the text "Sim" on it, and I'm tryng to click on it, but proctactor can't find the element, why? 我有一个带有文本“ Sim”的按钮,并且我试图单击它,但是proctactor找不到该元素,为什么? It is on the screen. 它在屏幕上。

HTML 的HTML

 <button class="btn btn-primary" type="button">
              <i class="zmdi zmdi-check"></i>
                   Sim
            </button>

Test Code 测试代码

element(by.partialButtonText('Sim')).click();

Error 错误

Failed: element not visible 失败:元素不可见

Check for visibility of button using protractor.ExpectedCondtions. 使用量角器.ExpectedCondtions检查按钮的可见性。 You can use below code. 您可以使用以下代码。

Code Snippet: 代码段:

  var EC=protractor.ExpectedConditions;
  var buttonSim=element(by.xpath(".//*[contains(text(),'Sim')]"))

  browser.wait(EC.visibilityOf(buttonSim).call(),8000,'Button not visible');
  buttonSim.click();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM