在当前版本中,无法通过赛普拉斯访问新窗口

时间:2019-07-12 07:41:34

标签: cypress

我写了测试用例,可以从网站上购买笔记本电脑

describe("laptop from website ", function () {


    beforeEach(function () {
        cy.visit('https://www.amazon.in/', {
            onBeforeLoad(win) {
                cy.stub(win, 'open').as('windowOpen')
            }
        })
    })


    it("Search and Buy Laptop From amazon", function () {

        cy.get('#searchDropdownBox').select("All Categories", { force: true });
        cy.get('#twotabsearchtextbox').type("Laptop i7 processor, 8/16 GB RAM ");
        cy.get('.nav-search-submit > .nav-input').click();
        cy.get('[data-index="0"] > :nth-child(1) > [data-component-type="s-impression-logger"] > div.rush-component > .s-include-content-margin > .a-spacing-medium > :nth-child(2) > .sg-col-16-of-24 > :nth-child(1) > :nth-child(1) > .sg-col-4-of-12 > .sg-col-inner > :nth-child(1) > .a-size-mini > .a-link-normal > .a-size-medium').click();
        cy.visit('https://www.amazon.in/gp/slredirect/picassoRedirect.html/ref=pa_sp_mtf_aps_sr_pg1_1?ie=UTF8&adId=A079189026U6M04NWR9FI&url=%2FHP-Pavilion-15-6-inch-Windows-Graphics%2Fdp%2FB07F64D9XJ%2Fref%3Dsr_1_1_sspa%3Fkeywords%3D%2522Laptop%2Bi7%2Bprocessor%252C%2B8%252F16%2BGB%2BRAM%26qid%3D1562849061%26s%3Dgateway%26smid%3DA14CZOWI0VEHLG%26sr%3D8-1-spons%26psc%3D1&qualifier=1562849061&id=6042596282297865&widgetName=sp_mtf')

});




})

我要自动执行新窗口:这行代码

    cy.visit('https://www.amazon.in/gp/slredirect/picassoRedirect.html/ref=pa_sp_mtf_aps_sr_pg1_1?ie=UTF8&adId=A079189026U6M04NWR9FI&url=%2FHP-Pavilion-15-6-inch-Windows-Graphics%2Fdp%2FB07F64D9XJ%2Fref%3Dsr_1_1_sspa%3Fkeywords%3D%2522Laptop%2Bi7%2Bprocessor%252C%2B8%252F16%2BGB%2BRAM%26qid%3D1562849061%26s%3Dgateway%26smid%3DA14CZOWI0VEHLG%26sr%3D8-1-spons%26psc%3D1&qualifier=1562849061&id=6042596282297865&widgetName=sp_mtf')

正在新标签页中打开。

1 个答案:

答案 0 :(得分:0)

Cypress无法处理新的标签页或窗口。因此,这很简单(不可能在将来)。