
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
Advertisements