diff --git a/README.md b/README.md index b50cf48..59d3ad6 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,27 @@ -# 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 - +# SignUp Genius Automation + +This project automates the user registration and login process on the SignUpGenius website. The script demonstrates Selenium WebDriver's capabilities for interacting with dynamic web elements and handling browser-based automation tasks. + +## Features +- Automates the user registration process, including inputting personal details and solving a CAPTCHA manually. +- Automates the login process for the registered user. +- Includes JavaScript-based scrolling for seamless interaction with the page. +- Performs logout functionality to complete the user flow. + +## Prerequisites +Before running this project, ensure you have the following: +1. **Java Development Kit (JDK)** - Version 8 or above. +2. **Google Chrome** - Latest stable version. +3. **ChromeDriver** - Version compatible with your Google Chrome browser. +4. **Selenium WebDriver** - Included in the project dependencies. +5. **CAPTCHA solving capability** - The script pauses for manual CAPTCHA solving. + +## Technologies Used +- **Java** - The programming language for automation. +- **Selenium WebDriver** - For interacting with web elements and automating browser actions. +- **Google Chrome & ChromeDriver** - For browser automation. +- **JavaScript Executor** - For advanced browser interactions such as scrolling. + +## Notes +- The script includes pauses (`Thread.sleep`) for better visibility of the process and user actions. +- CAPTCHA solving requires manual intervention, as automated CAPTCHA solutions are not implemented. diff --git a/ToolsQA_Project/.classpath b/SignUpGenius_Project/.classpath similarity index 100% rename from ToolsQA_Project/.classpath rename to SignUpGenius_Project/.classpath diff --git a/ToolsQA_Project/.project b/SignUpGenius_Project/.project similarity index 90% rename from ToolsQA_Project/.project rename to SignUpGenius_Project/.project index 7cf210a..a9a0538 100644 --- a/ToolsQA_Project/.project +++ b/SignUpGenius_Project/.project @@ -1,6 +1,6 @@ - ToolsQA_Project + SignUpGenius_Project diff --git a/ToolsQA_Project/.settings/org.eclipse.core.resources.prefs b/SignUpGenius_Project/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from ToolsQA_Project/.settings/org.eclipse.core.resources.prefs rename to SignUpGenius_Project/.settings/org.eclipse.core.resources.prefs diff --git a/ToolsQA_Project/.settings/org.eclipse.jdt.core.prefs b/SignUpGenius_Project/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from ToolsQA_Project/.settings/org.eclipse.jdt.core.prefs rename to SignUpGenius_Project/.settings/org.eclipse.jdt.core.prefs diff --git a/SignUpGenius_Project/bin/sign_up_genius/SignUp_Form.class b/SignUpGenius_Project/bin/sign_up_genius/SignUp_Form.class new file mode 100644 index 0000000..0719ae7 Binary files /dev/null and b/SignUpGenius_Project/bin/sign_up_genius/SignUp_Form.class differ diff --git a/SignUpGenius_Project/src/sign_up_genius/SignUp_Form.java b/SignUpGenius_Project/src/sign_up_genius/SignUp_Form.java new file mode 100644 index 0000000..beca051 --- /dev/null +++ b/SignUpGenius_Project/src/sign_up_genius/SignUp_Form.java @@ -0,0 +1,116 @@ +package sign_up_genius; + +import java.time.Duration; +import java.util.Scanner; +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 SignUp_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://www.signupgenius.com/register"); + waitForTheUser(); + + WebElement signupButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[text()='Create a Sign Up']"))); + signupButton.click(); + waitForTheUser(); + + WebElement firstNameField = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='firstNameId']"))); + firstNameField.click(); + firstNameField.sendKeys("Chris"); + waitForTheUser(); + + WebElement lastNameField = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='lastNameId']"))); + lastNameField.click(); + lastNameField.sendKeys("Redfield"); + waitForTheUser(); + + WebElement emailIDField = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='myEmailId']"))); + emailIDField.click(); + emailIDField.sendKeys("chrisredfield@gmail.com"); + waitForTheUser(); + + WebElement passWordField = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='pwordId']"))); + passWordField.click(); + passWordField.sendKeys("Cr@!ADA21309"); + waitForTheUser(); + + WebElement viewPassWord = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"registration\"]/form/div/div[5]/div/span"))); + viewPassWord.click(); + waitForTheUser(); + viewPassWord.click(); + waitForTheUser(); + + JavascriptExecutor scrollDownOne = (JavascriptExecutor) driver; + scrollDownOne.executeScript("window.scrollBy(0,100)"); + 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 + waitForTheUser(); + + WebElement registerButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@value='Register Now']"))); + registerButton.click(); + waitForTheUser(); + + /*WebElement logoutButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@class='logoutLink']"))); + logoutButton.click(); + waitForTheUser();*/ + + WebElement loginButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[text()='Log In']"))); + loginButton.click(); + waitForTheUser(); + + WebElement emailIdField = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='email']"))); + emailIdField.click(); + emailIdField.sendKeys("chrisredfield@gmail.com"); + waitForTheUser(); + + WebElement loginPasswordField = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@type='password']"))); + loginPasswordField.click(); + loginPasswordField.sendKeys("Cr@!ADA21309"); + waitForTheUser(); + + WebElement submitField = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@value='Login']"))); + submitField.click(); + waitForTheUser(); + + JavascriptExecutor scrollDownTwo = (JavascriptExecutor) driver; + scrollDownTwo.executeScript("window.scrollBy(0,800)"); + waitForTheUser(); + + JavascriptExecutor scrollUp = (JavascriptExecutor) driver; + scrollUp.executeScript("window.scrollBy(0,-800)"); + waitForTheUser(); + + WebElement profileButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"main-nav\"]/div/div[1]/div/div/div"))); + profileButton.click(); + waitForTheUser(); + + WebElement logoutButton = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@class='logoutLink']"))); + logoutButton.click(); + waitForTheUser(); + + driver.quit(); + } + + public static void waitForTheUser() { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } +} 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(); - } - } -}