- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
TestNG error:- Cannot find class in classpath using Selenium
We may encounter Cannot find class in classpath exception while executing tests in Selenium with TestNG framework. This can be caused because of the following reasons −
In the TestNG XML, the class tag having the name attribute should not have the .java extension.
In the TestNG XML, the class file is incorrect and hence unable to determine the classpath of the class.
Errors within the project are present, and may require a clean project.
In the TestNG XML, the class file name is incorrect
The below image shows an example of this error −
Example
import org.testng.annotations.Test; public class TestNGP { @Test public void tC1() { System.out.println("Test Case 1"); } }
Example
TestNG XML Implementation
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd" > <suite name="Test> <test name="Tutorialspoint" > <classes> <class name="TestNGP" /> </classes> </test> </suite>
Output
- Related Articles
- How to install TestNG in eclipse using Selenium?
- What can cause a Cannot find symbol error in java?
- What can cause the "cannot find symbol" error in Java?
- Is TestNG part of selenium?
- How to run multiple test cases using TestNG Test Suite in Selenium?
- Capturing JavaScript error in Selenium.
- How to find an element using the attribute “class name” in Selenium?
- How to handle SSL certificate error using Selenium WebDriver?
- Unable to locate an element using xpath error in selenium-java
- How to capture tooltip in Selenium using Actions Class?
- Find div element by multiple class names in Selenium?
- Bootstrap .has-error class
- How to get css class name using Selenium?
- What is the difference between selenium WebDriver and TestNG?
- How To Use TestNG Framework For Creating Selenium Scripts?

Advertisements