diff --git a/ToolsQA_Project/.classpath b/Lambdatest Playground/.classpath similarity index 100% rename from ToolsQA_Project/.classpath rename to Lambdatest Playground/.classpath diff --git a/ToolsQA_Project/.project b/Lambdatest Playground/.project similarity index 90% rename from ToolsQA_Project/.project rename to Lambdatest Playground/.project index 7cf210a..d1c0497 100644 --- a/ToolsQA_Project/.project +++ b/Lambdatest Playground/.project @@ -1,6 +1,6 @@ - ToolsQA_Project + Lambdatest Playground diff --git a/ToolsQA_Project/.settings/org.eclipse.core.resources.prefs b/Lambdatest Playground/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from ToolsQA_Project/.settings/org.eclipse.core.resources.prefs rename to Lambdatest Playground/.settings/org.eclipse.core.resources.prefs diff --git a/ToolsQA_Project/.settings/org.eclipse.jdt.core.prefs b/Lambdatest Playground/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from ToolsQA_Project/.settings/org.eclipse.jdt.core.prefs rename to Lambdatest Playground/.settings/org.eclipse.jdt.core.prefs diff --git a/Lambdatest Playground/bin/lambdatest_project/Lambdatest_Registration.class b/Lambdatest Playground/bin/lambdatest_project/Lambdatest_Registration.class new file mode 100644 index 0000000..60c4eea Binary files /dev/null and b/Lambdatest Playground/bin/lambdatest_project/Lambdatest_Registration.class differ diff --git a/Lambdatest Playground/src/lambdatest_project/Lambdatest_Registration.java b/Lambdatest Playground/src/lambdatest_project/Lambdatest_Registration.java new file mode 100644 index 0000000..9fac809 --- /dev/null +++ b/Lambdatest Playground/src/lambdatest_project/Lambdatest_Registration.java @@ -0,0 +1,127 @@ +package lambdatest_project; + +import java.time.Duration; +import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; + +public class Lambdatest_Registration { + + public static void main(String[] args) { + WebDriver driver = new ChromeDriver(); + driver.manage().window().maximize(); + + WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10)); + driver.get("https://ecommerce-playground.lambdatest.io/index.php?route=account/login"); + waitForTheUser(); + + WebElement continueButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@class='btn btn-primary']"))); + continueButton.click(); + waitForTheUser(); + + WebElement firstName = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='firstname']"))); + firstName.click(); + firstName.sendKeys("Ethan"); + waitForTheUser(); + + WebElement lastName = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='lastname']"))); + lastName.click(); + lastName.sendKeys("Winters"); + waitForTheUser(); + + WebElement emailField = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='email']"))); + emailField.click(); + emailField.sendKeys("ethanwinters1984@gmail.com"); + waitForTheUser(); + + JavascriptExecutor scrollDownOne = (JavascriptExecutor) driver; + scrollDownOne.executeScript("window.scrollBy(0,400)"); + waitForTheUser(); + + WebElement telePhone = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='telephone']"))); + telePhone.click(); + telePhone.sendKeys("(337) 555-0199"); + waitForTheUser(); + + WebElement passWord = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='password']"))); + passWord.click(); + passWord.sendKeys("EthanwinterS@1984"); + waitForTheUser(); + + WebElement confirmPassword = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@name='confirm']"))); + confirmPassword.click(); + confirmPassword.sendKeys("EthanwinterS@1984"); + waitForTheUser(); + + WebElement subscribeButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//label[@for='input-newsletter-yes']"))); + subscribeButton.click(); + waitForTheUser(); + + WebElement policyButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("(//label[@class='custom-control-label'])[3]"))); + policyButton.click(); + waitForTheUser(); + + WebElement submitButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@type='submit']"))); + submitButton.click(); + waitForTheUser(); + + WebElement loginMessage = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//h1[@class='page-title my-3']"))); + System.out.println("Login Message: " + loginMessage.getText()); + System.out.println("Congratulations! Your new account has been successfully created!"); + waitForTheUser(); + + WebElement proceedButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[text()='Continue']"))); + proceedButton.click(); + waitForTheUser(); + + JavascriptExecutor scrollDownTwo = (JavascriptExecutor) driver; + scrollDownTwo.executeScript("window.scrollBy(0,400)"); + waitForTheUser(); + + WebElement logoutButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//i[@class='fas fa-sign-out-alt fa-fw mr-1']"))); + logoutButton.click(); + waitForTheUser(); + + WebElement logoutMessage = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//h1[@class='page-title my-3']"))); + System.out.println(); + System.out.println("Logout Message: " + logoutMessage.getText()); + System.out.println("You have been logged off your account. It is now safe to leave the computer."); + waitForTheUser(); + + WebElement logoutContinue = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[@class='btn btn-primary']"))); + logoutContinue.click(); + waitForTheUser(); + + WebElement myAccount = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id=\"widget-navbar-217834\"]/ul/li[6]/a/div/span"))); + myAccount.click(); + waitForTheUser(); + + WebElement inputEmail = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='input-email']"))); + inputEmail.click(); + inputEmail.sendKeys("ethanwinters1984@gmail.com"); + waitForTheUser(); + + WebElement inputPassword = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='input-password']"))); + inputPassword.click(); + inputPassword.sendKeys("EthanwinterS@1984"); + waitForTheUser(); + + WebElement inputLogin = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@value='Login']"))); + inputLogin.click(); + waitForTheUser(); + + driver.quit(); + } + + public static void waitForTheUser() { + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} diff --git a/README.md b/README.md index b50cf48..1b9a7e3 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,33 @@ -# ToolsQA Automation Using Selenium - -### Description -This project demonstrates an automation script for user registration, login and logout on the ToolsQA demo application. The script interacts with the web elements on the registration and login pages to simulate a user performing the following tasks: -1. Registering a new account. -2. Logging in with the registered account. -3. Logging out of the account. - -The script uses Selenium WebDriver with Java and incorporates manual handling for CAPTCHA verification. - - -### Features -- Automates the registration process by filling in user details. -- Handles manual CAPTCHA solving with a pause in the script. -- Automates login and logout functionalities after successful registration. -- Alerts and confirmations are managed effectively in the script. -- Uses dynamic waits to handle varying page load times. - - -### Prerequisites -Before running the project, ensure the following are installed and set up: - -1. **Java Development Kit (JDK)**: Install JDK 8 or later and set up the environment variables. -2. **Selenium WebDriver**: Include the Selenium library in your project. You can add it using a dependency manager like Maven/Gradle or manually download it. -3. **WebDriver Binary**: Ensure the ChromeDriver binary is installed and matches your Chrome browser version. Place it in a directory included in your system's PATH or provide the path explicitly in the code. -4. **Browser**: Google Chrome browser installed on the system. -5. **IDE**: Use an Integrated Development Environment like IntelliJ IDEA or Eclipse to run the script. - - -### **Technologies Used** -- **Programming Language**: Java -- **Automation Framework**: Selenium WebDriver -- **Browser**: Google Chrome -- **Testing Environment**: ToolsQA Demo Page -- **Java Libraries**: - - Selenium Support Libraries (`org.openqa.selenium.*`) - - WebDriverWait and ExpectedConditions for dynamic waits - - Java Utilities like `Scanner` for user input - - JavaScript Executor for smooth scrolling - +# LambdaTest Playground Project + +## Project Description +This is an automation script designed to test the registration and login functionality of the Ecommerce Playground website. It utilizes Selenium WebDriver with Java to simulate user interactions, such as filling out forms, navigating through pages and verifying successful actions. This script automates the process of creating a new user account, logging out and re-logging in, ensuring the website's core features function as expected. + +--- + +## Features +1. Automates user registration with predefined data inputs. +2. Validates the success message for account creation. +3. Automates user logout and subsequent login. +4. Verifies the functionality of critical UI elements such as buttons, text fields, and messages. +5. Implements JavaScript scrolling to handle long web pages. +6. Includes delays to mimic real-world user interactions. + +--- + +## Prerequisites +- **Java Development Kit (JDK)** installed (version 11 or higher recommended). +- **Google Chrome** browser installed. +- **ChromeDriver** compatible with the installed Chrome browser version. +- **Eclipse IDE** or any other Java-supported IDE. +- **Selenium WebDriver** library added to the project. + +--- + +## Technologies Used +- **Java**: Programming language for writing the automation script. +- **Selenium WebDriver**: For browser automation. +- **Google Chrome & ChromeDriver**: Browser and corresponding WebDriver for executing the test. +- **JavaScriptExecutor**: For scrolling actions. +- **Explicit Waits**: To handle dynamic elements and ensure proper interaction. +- **Eclipse IDE**: Integrated Development Environment for Java development. diff --git a/ToolsQA_Project/bin/tools_qa_page/Registeration_Form.class b/ToolsQA_Project/bin/tools_qa_page/Registeration_Form.class deleted file mode 100644 index e93963c..0000000 Binary files a/ToolsQA_Project/bin/tools_qa_page/Registeration_Form.class and /dev/null differ diff --git a/ToolsQA_Project/src/tools_qa_page/Registeration_Form.java b/ToolsQA_Project/src/tools_qa_page/Registeration_Form.java deleted file mode 100644 index 15766f2..0000000 --- a/ToolsQA_Project/src/tools_qa_page/Registeration_Form.java +++ /dev/null @@ -1,99 +0,0 @@ -package tools_qa_page; - -import java.time.Duration; -import java.util.Scanner; - -import org.openqa.selenium.Alert; -import org.openqa.selenium.By; -import org.openqa.selenium.JavascriptExecutor; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.chrome.ChromeDriver; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; - -public class Registeration_Form { - - public static void main(String[] args) { - WebDriver driver = new ChromeDriver(); - driver.manage().window().maximize(); - - WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10)); - driver.get("https://demoqa.com/login"); - - WebElement newUser = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@id='newUser']"))); - newUser.click(); - waitForTheUser(); - - JavascriptExecutor scrollDownTwo = (JavascriptExecutor) driver; - scrollDownTwo.executeScript("window.scrollBy(0,200)"); - waitForTheUser(); - - WebElement firstName = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='firstname']"))); - firstName.click(); - firstName.sendKeys("Mia"); - waitForTheUser(); - - WebElement lastName = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='lastname']"))); - lastName.click(); - lastName.sendKeys("Winters"); - waitForTheUser(); - - WebElement userName = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='userName']"))); - userName.click(); - userName.sendKeys("mia@22"); - waitForTheUser(); - - WebElement passWord = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='password']"))); - passWord.click(); - passWord.sendKeys("MiaWinters@22!"); - waitForTheUser(); - - // Pause the script for manual CAPTCHA solving - System.out.println("Please solve the CAPTCHA manually and press Enter to continue..."); - Scanner scanner = new Scanner(System.in); - scanner.nextLine(); // Waits for user input - scanner.close(); // Close the Scanner to avoid resource leak - - WebElement registerButon = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@id='register']"))); - registerButon.click(); - waitForTheUser(); - - Alert simpleAlert = driver.switchTo().alert(); - simpleAlert.accept(); - System.out.println("Alert accepted successfully."); - waitForTheUser(); - - WebElement backButon = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("(//button[@type='button'])[3]"))); - backButon.click(); - waitForTheUser(); - - WebElement uName = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='userName']"))); - uName.click(); - uName.sendKeys("mia@22"); - waitForTheUser(); - - WebElement pWord = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='password']"))); - pWord.click(); - pWord.sendKeys("MiaWinters@22!"); - waitForTheUser(); - - WebElement loginButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@id='login']"))); - loginButton.click(); - waitForTheUser(); - - WebElement logoutButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("(//button[@type='button'])[2]"))); - logoutButton.click(); - waitForTheUser(); - - driver.close(); - } - - public static void waitForTheUser() { - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } -}