Cucumber cannot be resolved to a type Cucumber cannot be resolved to a type selenium selenium

Cucumber cannot be resolved to a type


I also faced the same issue in IntelliJ idea, When I check in the imported libraries it was like below screenshot.

screenshot

So I remove scope tag from my import in pom file.Then it worked.

Earlier

<dependency>    <groupId>info.cukes</groupId>    <artifactId>cucumber-junit</artifactId>    <version>1.2.5</version>    <scope>test</scope></dependency>

Fix

<dependency>    <groupId>info.cukes</groupId>    <artifactId>cucumber-junit</artifactId>    <version>1.2.5</version></dependency>

Now it is working fine


Import the cucumber.api.junit.Cucumber class. It seems you are using Eclipse IDE, so you can import the classes using the Ctrl+Shift+o (alphabet 'o' not zero) shortcut.

(Ctrl+Shift+O is 'Organise Imports', and will add any missing imports, remove any unused ones, and order all of your imports). The command is also found under Source > Organise Imports.


Just do Ctrl+Shift+T and type RunWith check if the jar is correctly imported into your work space after maven dependencies are resolved.