I want to get only the text \"Invitation sent to xxxxx\", I do not want to get what\'s inside the
Given the HTML, you should be able to .getText(), split that text on a newline, and then take the first split to get the text you want.
.getText()
driver.findElement(By.cssSelector("p.artdeco-toast-message")).getText().split("\r\n")[0];