Get some text with java + selenium WebDriver

后端 未结 4 1562
深忆病人
深忆病人 2020-12-12 02:08

I want to get only the text \"Invitation sent to xxxxx\", I do not want to get what\'s inside the

4条回答
  •  情歌与酒
    2020-12-12 02:43

    In fact Selenium's getText() method retrieves all the text in sub elements too, so the approach, recommended by Murthi is the most applicable, as far as I know. Try this approach:

    String newLine = System.getProperty("line.separator");
    String pessoapopu = driver.findElement(By.className("artdeco-toast-message"))
                               .getText().replaceAll(newLine, "");
    

    Or try/ask for more convenient HTML code.

提交回复
热议问题