PsiElement (@NotNull final String fileName) { final VirtualFile virtualFile = myFixture.getTempDirFixture().getFile(fileName); assert virtualFile != null : "Can't find " + fileName; // Configure context by folder in case of folder, or by element if file final PsiElement elementToRightClickOn; if (virtualFile.isDirectory()) { elementToRightClickOn = PsiDirectoryFactory.getInstance(getProject()).createDirectory(virtualFile); } else { myFixture.configureByFile(fileName); elementToRightClickOn = myFixture.getElementAtCaret(); } return elementToRightClickOn; }