【发布时间】:2020-07-20 05:13:36
【问题描述】:
我有非常奇怪的场景,我不知道如何处理它。
我是测试新手,我有一个网站可以测试我们检查购物车功能的工作属性。
我的问题是我们添加了 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