Search code examples
mavenseleniumwebdriver-manager

WebDriverManager The import io.github cannot be resolved


I added the below WebDriverManager maven dependency in pom.xml

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
</dependency> 

In my java class I am unable to import io.github.bonigarcia.wdm.WebDriverManager; automatically. If manually write the import, I get error at io.github which says: The import io.github cannot be resolved.

What is the issue here? I tried clean, restart and different versions of webdrivermanager in pom.xml.

enter image description here


Solution

  • <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency> 
    

    The dependency you used is reduced to <scope>test</scope> but what that actually means? It indicates that the dependency is NOT required for the compilation but only for execution.

    It appears during the runtime and test but not during compilation.

    The default scope is compile. Compile dependencies are available in all classpaths of the project.

    EDIT:

    <scope>test</scope> makes the dependency available for execution but not for compilation. What does it mean?

    It means that the classpath is available for src/test folder in your project.

    Default scope makes classpath available for src/main AND src/test. So if you make any classes manage WebDriver and you put them under source folder, you should use a scope which allows the dependency to be available at compilation time.