Reputation:
I have a maven project for Selenium tests project. All the necessary dependencies were defined in pom.xml like
selenium-java
webdrivermanager
assertj-core
testng
maven-surefire-plugin
maven-failsafe-plugin
slf4j-api
slf4j-simple
Now, I wrote a helper class, which has to serve as a common utility for the selenium tests located in folder src/test/java. This class has one static method with WebElement as a parameter for that I tried to import org.openqa.*.*classes. I am getting 'import org.openqa can't be resolved'
If I keep the class/method inside a selenium test class with in src/test/java folder it is resolving well. Why error is specific to src/main/java folder classes ?
Upvotes: 0
Views: 327
Reputation: 4349
Just adding the comment in answer . To use the selenium dependency in classes defined in src/main/java folder Make sure scope is defined for project.
`<scope>test</scope>`
Remove above scope from selenium dependency
`<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.5</version>
</dependency>
`
Upvotes: 0
Reputation:
@Rahul L comment answered the question. I should be marking it as an answer.
Upvotes: 0