Why do tests fail with 'cannot find ChromeDriver'?
Why do tests fail with 'cannot find ChromeDriver'?
Selenium 4 includes a built-in Selenium Manager that automatically downloads the correct ChromeDriver version for your installed Chrome. This error normally means one of the following:
- You are using an older Selenium version (below 4.6) that does not include Selenium Manager. Check your
pom.xmland confirmselenium-javais4.18.1. - Your machine does not have an internet connection at test runtime, so Selenium Manager cannot download the driver binary.
- There is a version mismatch between your Chrome browser and the cached ChromeDriver binary. Delete the cached binary (usually in
~/.cache/selenium) and let Selenium Manager re-download it.
How do I run tests in headless mode?
How do I run tests in headless mode?
The current Use
Hooks.setUp() creates a standard ChromeDriver with no options. To run headlessly, pass ChromeOptions with the --headless argument:--headless=new (not the legacy --headless) to get the Chromium-based headless mode that better matches visible Chrome rendering.Headless mode is recommended for CI pipelines where no display server is available.Why is AspectJ configured in the Surefire plugin?
Why is AspectJ configured in the Surefire plugin?
Allure uses AOP (Aspect-Oriented Programming) to intercept AspectJ version
@Step and @Attachment annotations at runtime. This interception is performed by the aspectjweaver Java agent.Without the -javaagent argument, the JVM does not load the weaver and Allure annotations are silently ignored — the report will show scenario-level pass/fail but no step-level data, attachments, or parameter details.The relevant section in pom.xml:1.9.21 is used because it supports Java 21. If you upgrade the Java version, also check for a compatible AspectJ release.What does the @smoke tag do and how do I create new tags?
What does the @smoke tag do and how do I create new tags?
How do I add a new test scenario?
How do I add a new test scenario?
Write the Gherkin scenario
Add a new
Scenario block to an existing .feature file in src/test/resources/features/, or create a new .feature file:Create or update a Page Object
If the scenario interacts with a new page, create a class that extends
BasePage in src/test/java/pages/. Use the inherited methods (click, type, getText, etc.) rather than calling Selenium directly.Implement the step definitions
Add
@Given, @When, and @Then methods to an existing or new step class in src/test/java/steps/. Inject TestContext via the constructor to access the shared WebDriver.Why does the framework use PicoContainer?
Why does the framework use PicoContainer?
Selenium tests written with Cucumber typically involve multiple step definition classes that all need to use the same
WebDriver instance. Without dependency injection, you would have to pass the driver between classes manually or use a static field — both of which lead to brittle, hard-to-maintain code.PicoContainer solves this by acting as an IoC container scoped to each scenario:- It creates a single
TestContextinstance at the start of the scenario. - It injects that instance into every class (hooks and step definitions) that declares a constructor accepting
TestContext. - All classes share the same
driverreference without any global state.
cucumber-picocontainer to pom.xml — Cucumber detects it on the classpath and activates it automatically.How do I run tests on Windows vs Linux?
How do I run tests on Windows vs Linux?
The Maven command is the same on both platforms:Platform-specific notes:
- Windows: Make sure
JAVA_HOMEpoints to a JDK 21 installation and that%JAVA_HOME%\binis on yourPATH. - Linux/macOS: Headless Chrome requires
google-chromeorchromium-browserto be installed. On a CI server with no display, add--headless=newtoChromeOptionsas shown in the headless mode FAQ above. - AspectJ javaagent path: The
${settings.localRepository}Maven property resolves correctly on all platforms. You do not need to hard-code a path.
What happens if a Selenium wait times out?
What happens if a Selenium wait times out?
All For a one-off longer wait in a specific step, create a local
BasePage methods use a WebDriverWait with a 10-second timeout. If the expected condition is not met within that window:- Methods that throw on timeout (
find,click,type,getText,locatorText): aTimeoutExceptionis propagated up to the step definition, which causes the Cucumber step to fail with a clear error message. - Methods with a built-in catch block (
isDisplayed,isClickable,isChecked): the exception is caught andfalseis returned instead of failing the test. This lets you write conditional logic without try-catch in your steps.
Duration in the BasePage constructor:WebDriverWait with its own timeout rather than modifying BasePage.How do I view test results without Allure installed?
How do I view test results without Allure installed?
You have two options:Option 1 — Use the Allure Maven plugin (no separate install needed)The This generates the report and opens it in your default browser via a temporary local HTTP server. No separate Allure CLI installation is required.Option 2 — Install the Allure CLIIf you want the Option 3 — TestNG default reportTestNG always generates a basic HTML report at
allure-maven plugin is already in pom.xml. Run:allure command available globally:target/surefire-reports/index.html. Open it in any browser — no extra tools needed.What browsers are supported?
What browsers are supported?
The framework currently supports Google Chrome only. The Then select the browser at runtime:Selenium 4’s built-in driver manager handles binary resolution for Firefox (
Hooks.setUp() method instantiates ChromeDriver directly.To add support for another browser, modify setUp() to accept a browser parameter (for example, via a system property) and instantiate the appropriate driver:geckodriver) and Edge (msedgedriver) automatically, just as it does for Chrome.