This program automates the process of registering a new user, logging in, browsing products, and completing a purchase on an e-commerce website. It uses random data to make the test more dynamic and checks for key functionalities like adding items to the cart and placing orders.
-
Setup (
MySetupmethod):- The
@BeforeTestannotation ensures this method runs first. - This method opens the browser, navigates to the store's homepage, and maximizes the browser window.
- The
-
Login and Registration Navigation (
LoginAndRegistmethod):- Navigates to the "Login or Register" page by clicking a link.
- Then proceeds to the registration form.
-
Registration (
Registrationmethod):- Fills out the registration form with random names, email, and address details.
- Selects a country and state from dropdown menus.
- Generates a random username and password, then submits the registration form.
-
Login (
LoginTestmethod):- Navigates to the login page and uses the credentials generated during registration to log in.
-
Selecting Men's Section (
SelectMenSectionmethod):- Navigates to the men's section of the store.
-
Selecting Random Main Product Category (
SelectRandomMainProductCatemethod):- Selects a random product category from the list on the page.
-
Selecting a Random Sub-Product (
GetRandomSubProductmethod):- Selects a random sub-product within the chosen category.
-
Checking for Product Availability (
CheckProductAvailabilitymethod):- Verifies product availability by checking if the "Add to Cart" button is enabled.
- If not available, navigates back to the men's section and repeats the process until a product is found.
-
Entering Random Quantity (
EnterRandomQuantitymethod):- Generates a random quantity (between 2 and 10) for the selected product.
- Inputs the quantity into the product's quantity field.
-
Adding Product to The Cart (
AddToCartmethod):- Adds the selected product with the selected quantity to the cart.
-
Checkout and Confirm Order (
CheckoutAndConfirmOrdermethod):- Clicks the checkout button and confirms the order to complete the purchase process.