void () { XmlFile file = (XmlFile)createFile("file.xml", "<a>x y</a>"); XmlTag tag = file.getDocument().getRootTag(); final XmlText xmlText = tag.getValue().getTextElements()[0]; ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(getProject(), () -> { try { xmlText.insertText("z", 1); } catch (IncorrectOperationException e) { throw new RuntimeException(e); } }, "", null, UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION)); assertEquals("<a>xz y</a>", tag.getText()); }