Skip to content

Commit 0d10cb3

Browse files
committed
Test Case 16: Place Order: Login before Checkout
1 parent bc8d586 commit 0d10cb3

File tree

6 files changed

+82
-24
lines changed

6 files changed

+82
-24
lines changed

src/test/java/com/automationexercise/tests/TestCase1.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class TestCase1 extends TestBasic {
2424
2. Navigate to url 'http://automationexercise.com'
2525
3. Verify that home page is visible successfully
2626
4. Click on 'Signup / Login' button
27-
5. Verify 'New User Signup!' is visible
27+
5. Verify 'New User Signup!' is visible]
2828
6. Enter name and email address
2929
7. Click 'Signup' button
3030
8. Verify that 'ENTER ACCOUNT INFORMATION' is visible
@@ -35,7 +35,7 @@ public class TestCase1 extends TestBasic {
3535
13. Click 'Create Account button'
3636
14. Verify that 'ACCOUNT CREATED!' is visible
3737
15. Click 'Continue' button
38-
16. Verify that 'Logged in as username' is visible
38+
16. Verify that 'Logged in as username' is visible]
3939
17. Click 'Delete Account' button
4040
18. Verify that 'ACCOUNT DELETED!' is visible and click 'Continue' button""")
4141
public void registerUser() throws IOException, ParseException {
@@ -47,48 +47,48 @@ public void registerUser() throws IOException, ParseException {
4747
verifyThatAccountDeletedIsVisibleAndClickContinueButton();
4848
}
4949

50-
@Step("3. Verify that home page is visible successfully")
50+
@Step("Verify that home page is visible successfully")
5151
public static void verifyThatHomePageIsVisibleSuccessfully() {
5252
boolean homePageVisible = new HomePage(getDriver())
5353
.homePageIsVisible()
5454
.isDisplayed();
55-
Assert.assertTrue(homePageVisible, "3. Verify that home page is visible successfully");
55+
Assert.assertTrue(homePageVisible, "Verify that home page is visible successfully");
5656
}
5757

58-
@Step("5. Verify 'New User Signup!' is visible")
58+
@Step("Verify 'New User Signup!' is visible")
5959
public static void verifyNewUserSignupIsVisible() {
6060
String newUserSignupText = new HomePage(getDriver())
6161
.signupLoginClick()
6262
.getNewUserSignup()
6363
.getText();
64-
Assert.assertEquals(newUserSignupText, "New User Signup!", "5. Verify 'New User Signup!' is visible");
64+
Assert.assertEquals(newUserSignupText, "New User Signup!", "Verify 'New User Signup!' is visible");
6565
}
6666

67-
@Step("8. Verify that 'ENTER ACCOUNT INFORMATION' is visible")
67+
@Step("Verify that 'ENTER ACCOUNT INFORMATION' is visible")
6868
private void verifyThatEnterAccountInformationIsVisible() {
6969
String enterAccountInformationText = new LoginSignupPage(getDriver())
7070
.fillCorrectSignup(name, email)
7171
.getEnterAccountInformation()
7272
.getText();
73-
Assert.assertEquals(enterAccountInformationText, "ENTER ACCOUNT INFORMATION", "8. Verify that 'ENTER ACCOUNT INFORMATION' is visible");
73+
Assert.assertEquals(enterAccountInformationText, "ENTER ACCOUNT INFORMATION", "Verify that 'ENTER ACCOUNT INFORMATION' is visible");
7474
}
7575

76-
@Step("14. Verify that 'ACCOUNT CREATED!' is visible")
76+
@Step("Verify that 'ACCOUNT CREATED!' is visible")
7777
private void verifyThatAccountCreatedIsVisible() throws IOException, ParseException {
7878
String accountCreatedText = new EnterAccountInformationPage(getDriver())
7979
.fillAccountDetails()
8080
.getAccountCreated()
8181
.getText();
82-
Assert.assertEquals(accountCreatedText, "ACCOUNT CREATED!", "14. Verify that 'ACCOUNT CREATED!' is visible");
82+
Assert.assertEquals(accountCreatedText, "ACCOUNT CREATED!", "Verify that 'ACCOUNT CREATED!' is visible");
8383
}
8484

85-
@Step("16. Verify that 'Logged in as username' is visible")
85+
@Step("Verify that 'Logged in as username' is visible")
8686
private void verifyThatLoggedInAsUsernameIsVisible() {
8787
String username = new AccountCreatedPage(getDriver())
8888
.continueButtonClick()
8989
.getUsername()
9090
.getText();
91-
Assert.assertEquals(username, name, "16. Verify that 'Logged in as username' is visible");
91+
Assert.assertEquals(username, name, "Verify that 'Logged in as username' is visible");
9292
}
9393

9494
@Step("Verify that 'ACCOUNT DELETED!' is visible and click 'Continue' button")

src/test/java/com/automationexercise/tests/TestCase14.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static void verifyThatCartPageIsDisplayed() {
6161
Assert.assertEquals(shoppingCartText, "Shopping Cart", "Verify that cart page is displayed");
6262
}
6363

64-
@Step("10. Verify 'ACCOUNT CREATED!' and click 'Continue' button")
64+
@Step("Verify 'ACCOUNT CREATED!' and click 'Continue' button")
6565
private void verifyAccountCreatedAndClickContinueButton() throws IOException, ParseException {
6666
String accountCreatedText = new CartPage(getDriver())
6767
.proceedToCheckoutButtonClick()
@@ -71,16 +71,16 @@ private void verifyAccountCreatedAndClickContinueButton() throws IOException, Pa
7171
.getAccountCreated()
7272
.getText();
7373

74-
Assert.assertEquals(accountCreatedText, "ACCOUNT CREATED!", "10. Verify 'ACCOUNT CREATED!'");
74+
Assert.assertEquals(accountCreatedText, "ACCOUNT CREATED!", "Verify 'ACCOUNT CREATED!'");
7575
new AccountCreatedPage(getDriver()).continueButtonClick();
7676
}
7777

78-
@Step("11. Verify ' Logged in as username' at top")
78+
@Step("Verify ' Logged in as username' at top")
7979
private void verifyLoggedInAsUsernameAtTop() {
8080
String username = new LoggedHomePage(getDriver())
8181
.getUsername()
8282
.getText();
83-
Assert.assertEquals(username, name, "11. Verify ' Logged in as username' at top");
83+
Assert.assertEquals(username, name, "Verify ' Logged in as username' at top");
8484
}
8585

8686
@Step("Verify Address Details and Review Your Order")

src/test/java/com/automationexercise/tests/TestCase15.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class TestCase15 extends TestBasic {
4040
15. Click 'Pay and Confirm Order' button
4141
16. Verify success message 'Congratulations! Your order has been confirmed!'
4242
17. Click 'Delete Account' button
43-
18. Verify 'ACCOUNT DELETED!' and click 'Continue' button""")
43+
18. Verify that 'ACCOUNT DELETED!' and click 'Continue' button""")
4444
public void placeOrderRegisterBeforeCheckout() throws IOException, ParseException {
4545
TestCase1.verifyThatHomePageIsVisibleSuccessfully();
4646
verifyAccountCreatedAndClickContinueButton();
@@ -52,23 +52,23 @@ public void placeOrderRegisterBeforeCheckout() throws IOException, ParseExceptio
5252
TestCase1.verifyThatAccountDeletedIsVisibleAndClickContinueButton();
5353
}
5454

55-
@Step("6. Verify 'ACCOUNT CREATED!' and click 'Continue' button")
55+
@Step("Verify 'ACCOUNT CREATED!' and click 'Continue' button")
5656
private void verifyAccountCreatedAndClickContinueButton() throws IOException, ParseException {
5757
String accountCreatedText = new HomePage(getDriver())
5858
.signupLoginClick()
5959
.fillCorrectSignup(name, email)
6060
.fillAccountDetails()
6161
.getAccountCreated()
6262
.getText();
63-
Assert.assertEquals(accountCreatedText, "ACCOUNT CREATED!", "6. Verify 'ACCOUNT CREATED!'");
63+
Assert.assertEquals(accountCreatedText, "ACCOUNT CREATED!", "Verify 'ACCOUNT CREATED!'");
6464
new AccountCreatedPage(getDriver()).continueButtonClick();
6565
}
6666

67-
@Step("7. Verify ' Logged in as username' at top")
67+
@Step("Verify ' Logged in as username' at top")
6868
private void verifyLoggedInAsUsernameAtTop() {
6969
String username = new LoggedHomePage(getDriver())
7070
.getUsername()
7171
.getText();
72-
Assert.assertEquals(username, name, "7. Verify ' Logged in as username' at top");
72+
Assert.assertEquals(username, name, "Verify ' Logged in as username' at top");
7373
}
7474
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.automationexercise.tests;
2+
3+
import com.automationexercise.pages.CartPage;
4+
import com.automationexercise.pages.HomePage;
5+
import com.automationexercise.pages.LoggedHomePage;
6+
import com.automationexercise.utils.JSONReader;
7+
import io.qameta.allure.*;
8+
import org.json.simple.parser.ParseException;
9+
import org.testng.Assert;
10+
import org.testng.annotations.Test;
11+
12+
import java.io.IOException;
13+
14+
@Epic("Regression Tests")
15+
@Feature("Place Order")
16+
public class TestCase16 extends TestBasic {
17+
18+
@Test(description = "Test Case 16: Place Order: Login before Checkout")
19+
@Severity(SeverityLevel.CRITICAL)
20+
@Story("Place Order: Login before Checkout")
21+
@Description("""
22+
1. Launch browser
23+
2. Navigate to url 'http://automationexercise.com'
24+
3. Verify that home page is visible successfully
25+
4. Click 'Signup / Login' button
26+
5. Fill email, password and click 'Login' button
27+
6. Verify 'Logged in as username' at top
28+
7. Add products to cart
29+
8. Click 'Cart' button
30+
9. Verify that cart page is displayed
31+
10. Click Proceed To Checkout
32+
11. Verify Address Details and Review Your Order
33+
12. Enter description in comment text area and click 'Place Order'
34+
13. Enter payment details: Name on Card, Card Number, CVC, Expiration date
35+
14. Click 'Pay and Confirm Order' button
36+
15. Verify success message 'Your order has been placed successfully!'""")
37+
public void placeOrderLoginBeforeCheckout() throws IOException, ParseException {
38+
TestCase1.verifyThatHomePageIsVisibleSuccessfully();
39+
new HomePage(getDriver())
40+
.signupLoginClick()
41+
.fillCorrectLogin(JSONReader.existingUser("email"), JSONReader.existingUser("password"));
42+
verifyLoggedInAsUsernameAtTop();
43+
TestCase14.verifyThatCartPageIsDisplayed();
44+
new CartPage(getDriver()).proceedToCheckoutButtonClick();
45+
TestCase14.verifyAddressDetailsAndReviewYourOrder();
46+
TestCase14.verifySuccessMessageCongratulationsYourOrderHasBeenConfirmed();
47+
}
48+
49+
@Step("Verify 'Logged in as username' at top")
50+
private void verifyLoggedInAsUsernameAtTop() throws IOException, ParseException {
51+
String username = new LoggedHomePage(getDriver())
52+
.getUsername()
53+
.getText();
54+
Assert.assertEquals(username, JSONReader.existingUser("name"), "Verify 'Logged in as username' at top");
55+
}
56+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "robert212197331002",
3-
"email": "robert212197331002@test.pl",
4-
"password": "robert212197331002@test.pl"
2+
"name": "robert998877662213",
3+
"email": "robert998877662213@o2.pl",
4+
"password": "robert998877662213@o2.pl"
55
}

testing.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<class name="com.automationexercise.tests.TestCase12"/>
1818
<class name="com.automationexercise.tests.TestCase13"/>
1919
<class name="com.automationexercise.tests.TestCase14"/>
20+
<class name="com.automationexercise.tests.TestCase15"/>
21+
<class name="com.automationexercise.tests.TestCase16"/>
2022
</classes>
2123
</test>
2224
</suite>

0 commit comments

Comments
 (0)