There are exactly 4 errors as follows:
-
Error: ChromeDriver cannot be resolved to a type
-
Solution: You need to add the following import
import org.openqa.selenium.chrome.ChromeDriver;
- Here you can find a discussion on chrome Webdriver can’t be resolved to a type error eclipse and java
-
-
Error: Test cannot be resolved to a type
-
Solution: You need to add the following import
import org.testng.annotations.Test; //or import org.junit.Test;
-
-
Error: The public type ChromeTest must be defined in its own file
-
Solution: Your filename is Chrom.java but your classname is ChromeTest where as both should have been similar. Change them as identical.
-
Here you can find a discussion on “The public type must be defined in its own file” but the file name and the class name is the same
-
-
Error: WebDriver cannot be resolved to a type
-
Solution: You need to add the following import
import org.openqa.selenium.WebDriver;
-
Best Practice
- You have to keep the filename (currently Chrom.java) and your classname (currently ChromeTest) identical as a mandatory measure.
- You need to mention the related imports whenever you are using any class. You can Mouse Hover over the error and choose the relevant import.
- You should either add the testng jars or the junit jars but not both of them.