void () { final XmlTag tag = createTag("foo.xhtml", "<p>a<div/>b</p>"); final XmlTag div = tag.getSubTags()[0]; WriteCommandAction.writeCommandAction(getProject(), tag.getContainingFile()).run(() -> div.delete()); assertEquals("<p>ab</p>", tag.getText()); }