gpt4 book ai didi

javascript - Protractor 等待模态对话框

转载 作者:行者123 更新时间:2023-11-30 11:35:14 24 4
gpt4 key购买 nike

如何让 Protractor 等待 modal-dialog 弹出?

背景:单击按钮后, Protractor 应等待模式对话框弹出(并在单击按钮和弹出对话框时获取正确的时间)。我怎样才能做到这一点?使用 browser.wait()?

原因是,我必须进行端到端测试并测量用户从单击按钮到从网站获得反馈之间的体验时间。

当我手动进行测试时,网站可能需要 5 到 30 秒才能给出反馈。如何让 Protractor 等待,然后读出页面顶部显示的对话框?

最佳答案

因此,您需要测量单击按钮与 modal-dialogue 窗口出现之间的时间差。

  • 获取按钮点击后的时间

     //you can use any selector for clicking the button
    element(by.buttonText("button_text_for_thebutton").click();


    //getting the time
    var buttonClickTime = new date();
  • browser.wait() 中使用 预期条件 等待 modal-dialog 弹出

    //you can use any other locator for modal window
    browser.wait(EC.presenceOf(element(by.css('css_locator_formodal'))), 1000, 'Unable to find the modal-popup');

    //get the time post Modal dialog appearance
    var ModalDialogTime = new date();
  • 然后使用

    获取 buttonClickTimeModalDialogTime 之间的区别
    var timeDifference = ModalDialogTime.getTime() - buttonClickTime.getTime();

注意:预期条件代码取自 @alexce在此 SO 中回答 post .

关于javascript - Protractor 等待模态对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44756018/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com