A clean, modern Java-based web scraping template built with Selenium WebDriver and JUnit 4. This project is designed as a starting point for writing robust, browser-automated scrapers. It includes configurations and templates specifically tailored for scraping game data (titles, prices, and base prices) from e-commerce sites like GOG.com.
- Browser Automation: Powered by Selenium WebDriver to interact with dynamic, JavaScript-rendered web pages.
- Structured Template: Contains dedicated templates for target scrapers (
GameScraper) separate from the application entry point. - Testing Infrastructure: Pre-configured with JUnit 4 for writing automated verification tests for scrapers.
- IntelliJ Ready: Out-of-the-box support for IntelliJ IDEA projects using
.imlconfigurations.
Below is the directory tree of the key files in this repository:
├── assets/
│ └── scraper_banner.png # Repository banner image
├── src/
│ ├── GameScraper.java # Template class for GOG.com game scraping logic
│ └── Main.java # Main application entry point
├── WebScraper.iml # IntelliJ IDEA module configuration (libs, source folders)
└── .gitignore # Excludes IDE configs, build outputs, and system logs
- src/Main.java: Entry point for general environment testing.
- src/GameScraper.java: Draft template where the Selenium scraping workflow for GOG.com should be implemented.
- WebScraper.iml: Project configurations including dependencies on Selenium and JUnit 4.
Ensure you have the following installed on your machine:
- Java Development Kit (JDK): Version 21 or higher.
- IntelliJ IDEA: (Community or Ultimate edition) is highly recommended since dependencies are managed via the
.imlproject file. - Google Chrome / Firefox: A modern web browser to run the automation scripts.
- WebDrivers: Selenium Manager (included in modern Selenium 4.x) will automatically download the correct Chrome/Firefox driver, so manual driver installation is optional.
Follow these steps to set up the project locally:
git clone https://github.com/soniakshat/selenium-web-scraper-java.git
cd selenium-web-scraper-java- Open IntelliJ IDEA.
- Select Open or Import.
- Navigate to the
selenium-web-scraper-javafolder and select it. - IntelliJ will read the
WebScraper.imlfile and configure the project structure automatically.
If the dependencies (seleniumhq.selenium.java and JUnit4) are not automatically downloaded:
- Open the project settings (
Cmd + ;on macOS orCtrl + Alt + Son Windows). - Go to Project Structure > Libraries.
- Add
seleniumhq.selenium.javafrom Maven or configure your local JAR path.
- Navigate to
src/Main.javain the project explorer. - Click the green Run play button next to the class definition or the
mainmethod. - You should see
Hello world!printed in the console output.
- Add your Selenium scraping logic inside
src/GameScraper.java. - Click the green Run play button inside
GameScraper.javato start the browser-automation process.
This project is set up to run JUnit tests.
To run tests within IntelliJ:
- Right-click the
srcfolder (or individual test classes/methods when added). - Select Run 'All Tests' or click the run icon beside the test methods.
