I can write up and execute Selenium script without any special test framework but I wanted to use Junit 5 (because we have dependency with other tools) and I have never seen such error org.junit.jupiter.api.extension.ParameterResolutionException
while working with Junit 4.
Currently it's Junit 5 and I googled it to get some sort of idea but can not resolve the issue.
Test script using JUnit 5
, Eclipse 4.8
and Selenium
:
import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; public class loginTest { public WebDriver driver = null; public loginTest(WebDriver driver) { this.driver=driver; } @BeforeEach public void setUp() throws Exception { driver.get("google.com"); System.out.println("Page title is: " + driver.getTitle()); } @Test public void test() { // some action here I have in original script System.out.println("Page title is: " + driver.getTitle()); } @AfterEach public void tearDown() throws Exception { driver.quit(); } }
Stack trace:
org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [org.openqa.selenium.WebDriver arg0] in executable [public login.loginTest(org.openqa.selenium.WebDriver)]. at org.junit.jupiter.engine.execution.ExecutableInvoker.resolveParameter(ExecutableInvoker.java:191)
I had both @Test
and @ParameterizedTest
annotating the same method. I removed the former.
This error appears when you try to use both @Test
and @ParameterizedTest
in the same test class. Removing @Test
annotation will resolve the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With