如何与量角器配合使用

问题描述 投票:0回答:1

我有非常奇怪的情况,但不确定如何处理。

是测试人员中的新手,我有一个网站可以测试我们在哪里检查购物车功能的工作特性。

我的问题是,我们将x个产品相加,然后进行库存检查。如果存在库存冲突,那么我们需要在继续之前解决它,否则我们就继续。

我设法创建了一个看起来像这样的函数:

describe("Details page", function () {

    detailsPage = new DetailsPage();

    // The details page is accessible by the specified URL
    it(`Is defined by the URL: ${userData["url"]}${browser.baseUrl}`,
        async function () {
            await detailsPage.navigateDesktop();
        });

    // Details page has a form and it can be filled out with user data
    it("Has a form that can receive user data",
        async function() {
            await detailsPage.fillFormWithUserData();
            await utils.click(detailsPage.getForm().buttons.nextStep);
        });

    if (detailsPage.hasStockConflict()) {

        // Details page allows the user to fix conflicts in stocks
        it('Enables resolution of stock conflicts', async function () {
            // Wait for stock to fully load
            await detailsPage.hasStockConflict();
            await detailsPage.clickAllRemoveButtons();
            await detailsPage.clickAllDecreaseButtons();
        });

        // Details page allows the user to proceed to the next stage when all conflicts (if any) has been resolved
        it('Allows the user to proceed to the next stage of purchasing', async function () {
            const nextStepButton = detailsPage.getForm().buttons.nextStep;
            await utils.elementToBeClickable(nextStepButton);
            await utils.click(nextStepButton);
        });
    }
});

但是我的功能问题是,我需要等到从服务器返回响应,否则我确实会收到由以下原因触发的库存冲突:

hasStockConflict() //checks if there is stockConflict message in DOM

否则我将重定向到新页面。

我的问题是,我该如何在功能上进行排序以检查是否存在库存冲突,然后我们解决if语句,否则我们将继续而无需执行任何操作(这将带我进入下一页)?

我已将超时时间设置为1分钟。 1分钟后,它将以失败通过测试。

基本上,如果有股票冲突,我想解决if语句,否则我们基本上就跳过它。我可能误解了测试的目的,因此也将不胜感激!

javascript selenium if-statement jasmine protractor
1个回答
0
投票

每个测试都应对特定事物进行测试。它们不应包含if...else分支。相反,您应该针对每种情况进行测试。

© www.soinside.com 2019 - 2024. All rights reserved.