首页 > 解决方案 > 在测试中与来自其他域的网页交互

问题描述

我正在测试一个网上商店。当用户创建一个购物篮时。网站 (domain.de) 将用户重定向到 Stripe 支付系统。(条纹网)

现在,我想通过输入数据来完成付款。页面显示如下

在此处输入图像描述

该页面显示在一个新窗口中,屏幕左侧没有 cypress 测试步骤。

我努力了

cy.get(`[data-cy="checkout-button-desktop"] ion-button`)
        .last()
        .click({force: true}).then(()=>{

        cy.window().then((win) => {
            // Replace window.open(url, target)-function with our own arrow function
            cy.stub(win, 'open', url =>
            {
                // change window location to be same as the popup url
                win.location.href = url;
            }).as("popup") // alias it with popup, so we can wait refer it with @popup
        })

        cy.get("@popup").should("be.called")

        cy.get(`[id="cardNumber"]`).type(`5555555555554444`)
        cy.get(`[id="cardExpiry"]`).type(`02 / 22`)
        cy.get(`[id="cardCvc"]`).type(`022`)
        cy.get(`[id="billingName"]`).type(`Test Test`)
        // cy.xpath('//*[@id="root"]/div/div/div[2]/div/form/div[2]/div[4]/button/div[2]/span[1]').click({force: true});
        cy.get(`.SubmitButton-IconContainer`).click();
        cy.url().should('include', 'theoptical')

但它没有用。我没有任何从 cyperss 访问网页的权限

标签: stripe-paymentscypresse2e

解决方案


推荐阅读