Skip to content

Commit f40cf5d

Browse files
committed
Updted POM test case to be E2E
1 parent 5900861 commit f40cf5d

File tree

11 files changed

+205
-25
lines changed

11 files changed

+205
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
5. Tests run parallel on local browsers
1818
`npm run local-parallel`
1919

20-
6. Tests run on Docker Selenium Grid
20+
6. Tests run on Docker Selenium Grid. Make sure you have docker service running.
2121
`npm run docker`
2222

2323
7. Tests run parallel on Docker Selenium Grid

conf/wdio-local-pom.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var _ = require("lodash");
33

44
var overrides = {
55
specs: [
6-
'./test/specs/pom/**/login*.js'
6+
'./test/specs/pom/*.js'
77
],
88
};
99

File renamed without changes.

test/pageobjects/checkoutPage.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
const Page = require('./basePage');
2+
/**
3+
* sub page containing specific selectors and methods for a specific page
4+
*/
5+
class CheckoutPage extends Page {
6+
/**
7+
* define selectors using getter methods
8+
*/
9+
get firstNameInput() {
10+
return $('#firstNameInput')
11+
}
12+
13+
get lastNameInput() {
14+
return $('#lastNameInput')
15+
}
16+
17+
get addressLine1Input() {
18+
return $('#addressLine1Input')
19+
}
20+
21+
get provinceInput() {
22+
return $('#provinceInput')
23+
}
24+
25+
get postCodeInput() {
26+
return $('#postCodeInput')
27+
}
28+
29+
get checkoutShippingContinue() {
30+
return $('#checkout-shipping-continue')
31+
}
32+
33+
enterFirstName(firstName) {
34+
this.firstNameInput.setValue(firstName);
35+
}
36+
37+
enterLastName(lastName) {
38+
this.lastNameInput.setValue(lastName);
39+
}
40+
41+
enterAddressLine1(addressLine1) {
42+
this.addressLine1Input.setValue(addressLine1);
43+
}
44+
45+
enterProvince(province) {
46+
this.provinceInput.setValue(province);
47+
}
48+
49+
enterPostCode(postCode) {
50+
this.postCodeInput.setValue(postCode);
51+
}
52+
53+
clickSubmit() {
54+
this.checkoutShippingContinue.click();
55+
}
56+
57+
open() {
58+
return super.open('');
59+
}
60+
}
61+
62+
module.exports = new CheckoutPage();
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const Page = require('./basePage');
2+
/**
3+
* sub page containing specific selectors and methods for a specific page
4+
*/
5+
class ConfirmationPage extends Page {
6+
/**
7+
* define selectors using getter methods
8+
*/
9+
get confirmationMessage() {
10+
return $('#confirmation-message')
11+
}
12+
13+
get continueShoppingButton() {
14+
return $('div.continueButtonContainer button')
15+
}
16+
17+
clickContinueShoppingButton() {
18+
this.continueShoppingButton.click();
19+
}
20+
21+
waitForConfirmationToBeDisplayed() {
22+
this.confirmationMessage.waitForDisplayed({ timeout: 5000 });
23+
}
24+
25+
}
26+
27+
module.exports = new ConfirmationPage();

test/pageobjects/homePage.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const Page = require('./page');
1+
const Page = require('./basePage');
22
require('./signInPage');
3+
let phoneName = '';
34
/**
45
* sub page containing specific selectors and methods for a specific page
56
*/
@@ -11,10 +12,52 @@ class HomePage extends Page {
1112
return $('#signin')
1213
}
1314

15+
get ordersLink() {
16+
return $('#orders')
17+
}
18+
19+
get ordersLink() {
20+
return $('#orders')
21+
}
22+
23+
get iPhoneXSElement() {
24+
return $("//p[text() = 'iPhone XS']/../div[@class = 'shelf-item__buy-btn']")
25+
}
26+
27+
get phonesBuyButton() {
28+
return $("//p[text() = '" + phoneName + "']/../div[@class = 'shelf-item__buy-btn']")
29+
}
30+
31+
get cartCloseButton() {
32+
return $('.float-cart__close-btn')
33+
}
34+
35+
get buyButton() {
36+
return $('.buy-btn')
37+
}
38+
1439
navigateToSignIn() {
1540
this.signInLink.click();
1641
}
1742

43+
navigateToOrders() {
44+
this.ordersLink.click();
45+
}
46+
47+
selectPhone(phoneToSelect) {
48+
phoneName = phoneToSelect;
49+
this.phonesBuyButton.click();
50+
}
51+
52+
closeCartModal() {
53+
this.cartCloseButton.click();
54+
}
55+
56+
clickBuyButton() {
57+
this.buyButton.waitForClickable({ timeout: 5000 });
58+
this.buyButton.click();
59+
}
60+
1861
open() {
1962
return super.open('');
2063
}

test/pageobjects/ordersPage.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const Page = require('./basePage');
2+
3+
/**
4+
* sub page containing specific selectors and methods for a specific page
5+
*/
6+
class OrdersPage extends Page {
7+
/**
8+
* define selectors using getter methods
9+
*/
10+
get allOrders() {
11+
return $$('.order')
12+
}
13+
14+
get firstOrder() {
15+
return $('.order')
16+
}
17+
18+
waitforOrdersToDisplay() {
19+
this.firstOrder.waitForDisplayed({ timeout: 5000 });
20+
}
21+
}
22+
23+
module.exports = new OrdersPage();

test/pageobjects/signInPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const Page = require('./page');
1+
const Page = require('./basePage');
22

33
/**
44
* sub page containing specific selectors and methods for a specific page

test/specs/plain/orders.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ describe('Order a product', () => {
3131

3232
$("#confirmation-message").waitForDisplayed({ timeout: 5000 });
3333
expect($('#confirmation-message')).toHaveText('Your Order has been successfully placed.');
34-
3534
$("div.continueButtonContainer button").click();
35+
3636
$('#orders').click();
3737
$(".order").waitForDisplayed({ timeout: 5000 });
3838
expect($$('.order')).toHaveLength(1);

test/specs/pom/login.spec.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)