Waj
Waj

Reputation: 33

TestNG not available in selenium after adding TestNG in maven dependency (pom.xml)

I'm unable to execute my code under TestNG framework. I have added the dependencies and complied TestNG under scope in Eclipse. Please let me know how to get TestNG to be displayed. I can execute with JUnit but not TestNG.

<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>SignUpAccount</groupId>
        <artifactId>SignUpAccount</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <packaging>jar</packaging>
       <name>SignUpAccount</name>
       <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF8</project.build.sourceEncoding>
    </properties>

    <dependencies>
      <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.14.3</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency> 
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId> selenium-java </artifactId>
            <version>3.141.59</version> 
          </dependency>
    </dependencies>
</project>

enter image description here

Upvotes: 3

Views: 4140

Answers (3)

Sazib
Sazib

Reputation: 81

If you are use maven dependency need to change scope test to compile

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.14.3</version>
            <scope>compile</scope> // remove test and add this line 
        </dependency>

Upvotes: 1

Sameer Arora
Sameer Arora

Reputation: 4507

You need to install testng in your eclipse and then you would be able to see testng and its annotation. Please refer to the following link for its installation: http://testng.org/doc/download.html

Upvotes: 2

Ali
Ali

Reputation: 1689

Install TestNG plugin then try again, adding TestNG dependency alone will not work if you are running from Eclipse.

Upvotes: 2

Related Questions