Featured
DSA Interview Question
Question: Various S orting algorithms Answer: There are various sorting algorithms, each with its own advantages and disadvantages in terms ...
Maven Questions
-
Manage project dependencies through a centralized
pom.xmlfile. -
Compile, test, package and deploy applications.
-
Integrate with CI tools like Jenkins for continuous execution.
-
Ensure standard project structure and reproducibility across teams.
Types of Maven Lifecycles
Maven has 3 built-in lifecycles:
1️⃣ Default Lifecycle – Build & test the project
2️⃣ Clean Lifecycle – Clean old build files
3️⃣ Site Lifecycle – Generate project documentation
1️⃣ Clean Lifecycle - Deletes the target/ folder.
Used to remove previous build artifacts.
Phases:
pre-clean → clean → post-clean
Common command:
mvn clean
2️⃣ Default Lifecycle (Most Important for Selenium)
This lifecycle is used to compile code, run tests, and package the project.
Key Phases (Interview Focus)
| Phase | Purpose |
|---|---|
| validate | Checks project structure |
| compile | Compiles source code |
| test | Executes TestNG/JUnit tests |
| package | Creates JAR/WAR |
| verify | Verifies integration tests |
| install | Stores artifact in local repo |
| deploy | Deploys to remote repo |
🔹 How lifecycle works (Very Important)
If you run:
mvn test
Maven automatically runs:
validate → compile → test
If you run:
mvn install
Maven runs:
validate → compile → test → package → verify → install
🔹 Selenium Example
mvn clean test
Steps executed:
-
Deletes old
target/ -
Compiles code
-
Executes Selenium + TestNG tests
-
Generates reports
3️⃣ Site Lifecycle
Used to generate project documentation and reports.
Phases:
pre-site → site → post-site → site-deploy
Command:
mvn siteQuick Summary (Memorize)
mvn clean→ removes old build
mvn test→ runs Selenium tests
mvn install→ saves build to local repoMaven always executes previous phases automatically
pom.xml and what are its key elements?pom.xml (Project Object Model) is the core configuration file in Maven.Important elements:
-
<dependencies>– To manage external libraries. -
<build>– Custom build steps, plugins, test execution control. -
<repositories>– Define external repo URLs (e.g., Nexus). -
<properties>– Project-level config (e.g., Java version). -
<profiles>– For managing different environments (dev, QA, prod).
<dependencies> tag in pom.xml.Example:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.19.0</version> </dependency>
Maven downloads these automatically from the central repository or a custom one
compile, test, provided, and runtime scopes in Maven?This compiles tests but skips running them.
To skip compilation and execution:
mvn install -Dmaven.test.skip=true
clean, install, validate, package, and verify?popular posts
-
Question: What is WebDriverIO? Answer: WebDriverIO is a Node.js library that provides a WebDriver API implementation for web automation. It ...
-
There are thousands of cryptocurrencies available in addition to Bitcoin. Here are some notable examples: 1. Ethereum (ETH): Ethereum is th...
-
Question : Which command is used to maximize the browser window in WebdriverIO? browser.maximizeWindow() browser.maximize() browser.windowMa...