Hello @Farhan, you can use getText() method to capture the text from Alert Message. It will return a String variable and is used commonly to fetch data. You can use following command to get data from alert message:
driver.switchTo().alert().getText();
Here, we have used switchTo() method to switch the window handle to the alert window.