Handling browser pop-up windows with Selenium

后端 未结 5 1584
长情又很酷
长情又很酷 2020-12-14 08:41

We are running Selenium regression tests against our existing code base, and certain screens in our web app use pop-ups for intermediate steps.

Currently we use the

5条回答
  •  盖世英雄少女心
    2020-12-14 09:12

    I just trialled adding another selenium function, windowFocus():

    // force new window to open at this point - so we can select it later
    selenium().getEval("this.browserbot.getCurrentWindow().open('', 'enquiryPopup')");
    selenium().click("//input[@value='Submit']");
    selenium().windowFocus("enquiryPopup");
    selenium().waitForPopUp("enquiryPopup", getWaitTime());
    selenium().selectWindow("enquiryPopup");
    

    The test succeeded when I ran it locally, but only with all those method calls - create/focus/wait/select.

    I'm about to let the build server run all the tests, and if that succeeds too, I'll be making a library function out of it...!

提交回复
热议问题