Issue
I am working on Intellij IDE and trying to create extent report and whenever I create a reference of ExtentReports class, it doesn't recognize that variable i.e. whenever I use that variable to access the methods of that class it doesn't show the methods present in that class. Same thing is happening for WebDriver reference. It doesn't recognize the variable and also not showing the methods that are available in these classes or interfaces. I have already tried to do File->Invalidate cache and restart but it didn't resolve the issue. I have checked the dependency list and these Maven dependencies are present in the local repo. Please assist me in resolving this issue. I have added a pic of the code and IDE that I have worked. Kindly provide some help.
Solution
Your problem has nothing to to with caches and its validity. You're just breaking Java syntax.
You're trying to call method of a field inside enclosing class body. You need to have some method in your FrameworkReporter
and move your calls there, so that you would have something like this:
public class FrameworkReporter{
ExtentReports extent = new ExtentReports();
WebDriver driver = new ChromeDriver();
public void someMethod(){
extent.attachReporter();
driver.get("");
}
}
Answered By - Alexey R.
Answer Checked By - Katrina (JavaFixing Volunteer)