Inject Java Script to get display text

Hi

I want to inject a Java script to get text from a Popup that appear on pressing button on a webpage (this popup which is actually an error message cannot be captured via selector)

Can someone suggest step by step method to do it using “Inject JS” activity.

I ultimately want to do below

  • Via JS, get text from the pop-up

Please don’t suggest any other way apart from JS, as alternate way I have accomplished. I want to explore JS with this, and learn for advance cases.

Regards
Ankit