0

I am learning selenium testing using java with Intellij as the IDE and maven as the package manager.

My pom.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>depositTest</groupId>
    <artifactId>deposittest</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.9.10</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.53.0</version>
        </dependency>


    </dependencies>
</project>

My import statements are as follows:

import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.testng.annotations.AfterTest;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;
import static org.junit.Assert.*;
import static org.testng.AssertJUnit.assertEquals;
import org.openqa.selenium.WebDriver;

However, I get can not resolve symbol errors for the testng and junit libraries in the IDE. What am I doing wrong?

Echchama Nayak
  • 971
  • 3
  • 23
  • 44

1 Answers1

1

You have specified <scope>test</scope> in your <dependency> section for both JUnit and TestNG.

So those libraries are meant to be used only within src/test/java.

Please check if you are referring to these classes in src/main/java.

IntelliJ will not resolve the JUnit and TestNG classes in src/main/java

To fix your problem, please remove the <scope> tag from your <dependency> for both TestNG and JUnit, and try again.

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66