如何点击量角器中应用程序弹出窗口中的按钮?

时间:2015-11-06 10:23:10

标签: protractor

弹出窗口“否”按钮html代码:

<button type="button" class="btn btn-default" data-dismiss="modal">No</button>

弹出窗口“是”按钮html代码:

<button type="button" class="btn btn-primary" ng-click="sendBulkMail()">Yes</button>

完整代码:

<div class="modal-content">
            <div class="modal-body container-fluid mainformFieldsWrap">
                Are you sure you want to send bulk interest mail to candidates?
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
                <button type="button" class="btn btn-primary" ng-click="sendBulkMail()">Yes</button>
            </div>
        </div>

问题:在我们的应用程序中,点击“删除按钮”,点击删除按钮后弹出窗口,在弹出窗口中我必须点击“是”或“否”按钮。

怎么做?

1 个答案:

答案 0 :(得分:0)

如果您想在点击活动后实现任何服务电话或任何功能,我们可以使用以下内容:

   browser.driver.switchTo().activeElement(); 
   browser.sleep(5000); 
   element(by.buttonText("Yes")).click();
   browser.sleep(5000);

    element(by.css(".modal-content")).element(by.buttonText("Yes")).click();
    browser.sleep(5000);

   var DeclineBtn = element(by.buttonText('Yes'));    browser.executeScript("arguments[0].click()",DeclineBtn.getWebElement());
        browser.sleep(5000);

基本上,browser.sleep(5000)将让你的函数执行