-
Notifications
You must be signed in to change notification settings - Fork 2
/
checkout11-checkout1-logout.e2e.js
59 lines (43 loc) · 2.3 KB
/
checkout11-checkout1-logout.e2e.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const LoginPage = require('../pageobjects/login.page');
const InventoryPage = require('../pageobjects/inventory.page');
const CartPage = require('../pageobjects/cart.page');
const CheckoutStep1Page = require ('../pageobjects/checkoutstep1.page');
const CheckoutStep2Page = require('../pageobjects/checkoutstep2.page');
const CheckoutCompletePage = require ('../pageobjects/checkoutcomplete.page');
const LoginData = require('../../data/logindata');
const allureReporter = require('@wdio/allure-reporter').default;
describe('UserStory: Logout', () => {
allureReporter.addFeature('Logout');
// This is TestCase_2 modified with an intermediate logout-login from checkoutstep1 page
// State machine info:
// X 1 A 2 4 B 6 C 14(Logout) Y 1(Login) A 4 B 6 C 17 9 D 12 E
it("TestCase_11: (TestCase_2 modified) should be able to add one item to cart, logout on CheckoutStep1, log back in and check it out successfully", async ()=>{
await LoginPage.open();
await LoginPage.login(LoginData.userName, LoginData.password);
await InventoryPage.ensureOnPage();
await CartPage.addItemToCart('#add-to-cart-sauce-labs-backpack');
await CartPage.checkNumCartItems(1);
await CartPage.clickOnCartIcon();
await CartPage.clickOnCheckout();
await CheckoutStep1Page.ensureOnPage();
await LoginPage.logout();
await LoginPage.ensureOnLogoutPage();
// I should be on a login page already
await LoginPage.login(LoginData.userName, LoginData.password);
await InventoryPage.ensureOnPage();
await CartPage.checkNumCartItems(1);
await CartPage.clickOnCartIcon();
await CartPage.ensureOnPage();
await CartPage.checkNumCartItems(1);
await CartPage.clickOnCheckout();
await CheckoutStep1Page.ensureOnPage();
await CartPage.checkNumCartItems(1);
await CheckoutStep1Page.fillInCustomerInfo("Jane", "Doe", "90210");
await CheckoutStep1Page.clickOnContinue();
await CheckoutStep2Page.ensureOnPage();
await CartPage.checkNumCartItems(1);
await CheckoutStep2Page.clickOnFinish();
await CheckoutCompletePage.ensureOnPage();
await CartPage.checkNumCartItems(0);
})
});