Welcome to my JUnit Practice Repository! π This repository contains a collection of exercises I completed during my training sessions to strengthen my skills in JUnit testing. Each exercise showcases a practical implementation of various testing concepts, providing insights into how to ensure code quality and reliability using JUnit.
- Purpose: To demonstrate my learning and hands-on experience with JUnit, covering essential concepts such as unit testing, assertions, test annotations, and lifecycle methods.
- Scope: Exercises range from basic test cases to more advanced scenarios, ensuring a well-rounded understanding of JUnit testing.
- Tools Used:
- Programming Language: Java
- Testing Framework: JUnit
- IDE: IntelliJ IDEA / Eclipse (as applicable)
-
Web Driver Initialization:
A globalWebDriverinstance is used for seamless browser interaction, with@BeforeAlland@AfterAllannotations ensuring proper setup and teardown. -
Dynamic Locator Strategies:
Demonstrates diverse locator strategies for finding elements, such as:- ID, CSS Selectors, Tag Names, Class Names, and XPaths.
- Practical use of
findElementandfindElementsfor single or multiple element selection.
-
Form Handling:
Efficient form submission and validation by interacting with input fields and buttons, showcasing:- Data entry via locators.
- Result validation with
Assertions.
-
Mouse and Keyboard Actions:
Implementation of advanced interactions using theActionsclass, including:- Double-click, right-click, and single-click actions.
- Keyboard input handling with
Keys.
-
Alert Handling:
Comprehensive handling of browser alerts with methods for accepting or dismissing alerts and waiting mechanisms. -
Date Picker Interaction:
Simulates user interactions with a calendar widget to select a specific date. -
Dropdown Management:
Demonstrates:- Static dropdown selection using the
Selectclass. - Dynamic dropdown handling with scrolling and keyboard navigation.
- Static dropdown selection using the
-
Mouse Hover Operations:
Enables hover effects using theActionsclass for triggering dropdown menus. -
Window and Tab Management:
Efficient handling of multiple browser tabs/windows, including:- Switching between windows using
getWindowHandles. - Managing parent and child windows separately.
- Switching between windows using
-
File Uploads:
Automates file uploads by specifying file paths dynamically usingSystem.getProperty. -
Web Table Scraping:
Extracts and prints data from web tables, demonstrating:- Iteration through rows and cells.
- CSS selectors are used for precise data extraction.
-
Frame Handling:
Interacts with iframe elements by switching contexts usingdriver.switchTo().frame. -
Implicit Waits:
Usesdriver.manage().timeouts().implicitlyWaitto handle synchronization and improve test stability. -
Page Scrolling:
It includes a utility for scrolling to specific web page sections to enable seamless element interaction.
Iβve documented my learning journey and insights in a detailed Google Docs file. You can explore the notes for a deeper understanding of the concepts Iβve covered.
π View My Class Notes on Google Docs
-
Clone the repository:
git clone https://github.com/rashadkhan97/Junit-Practice-Exercise.git
-
Navigate to the project directory:
cd Junit-practice-exercises -
Open the project in your favorite Java IDE and explore the exercises!
This repository reflects my dedication to learning and mastering software testing using JUnit. If you find any insights or improvements, feel free to raise an issue or contribute through a pull request. π