0
0
Selenium Javatesting~8 mins

Selenium dependency configuration in Selenium Java - Framework Patterns

Choose your learning style9 modes available
Framework Mode - Selenium dependency configuration
Folder Structure
selenium-java-project/
├── pom.xml
├── src/
│   ├── main/
│   │   └── java/
│   │       └── com/example/app/  
│   └── test/
│       └── java/
│           └── com/example/tests/
│               ├── pages/
│               ├── tests/
│               └── utils/
└── README.md
  
Test Framework Layers
  • Dependency Management Layer: Managed by Maven through pom.xml to include Selenium and other libraries.
  • Page Object Layer: Java classes under src/test/java/com/example/tests/pages representing web pages.
  • Test Layer: Test classes under src/test/java/com/example/tests/tests containing test methods using TestNG or JUnit.
  • Utility Layer: Helper classes under src/test/java/com/example/tests/utils for reusable code like waits or driver setup.
  • Configuration Layer: Maven pom.xml and optionally property files for environment and browser settings.
Configuration Patterns

Use Maven pom.xml to declare Selenium dependencies with specific versions.

<dependencies>
  <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>4.10.0</version>
  </dependency>
</dependencies>

Use Maven profiles or property files to manage different environments or browsers.

Example: src/test/resources/config.properties to store URLs and credentials.

Test Reporting and CI/CD Integration
  • Integrate TestNG or JUnit reports generated during test runs.
  • Use Maven Surefire Plugin to run tests and generate reports.
  • Configure CI/CD pipelines (e.g., Jenkins, GitHub Actions) to run tests on code commits.
  • Publish reports as build artifacts or use plugins for HTML reports.
Best Practices
  • Pin Selenium dependency versions in pom.xml to avoid unexpected breaks.
  • Use Maven dependency management to handle transitive dependencies cleanly.
  • Keep configuration (URLs, credentials) outside code in property files.
  • Use profiles in Maven for different environments (dev, test, prod).
  • Regularly update dependencies but test compatibility before upgrading.
Self Check

Where in this folder structure would you add a new utility class for custom waits?

Key Result
Manage Selenium dependencies via Maven pom.xml with clear versioning and separate configuration files.