How do you capture the message from Firefox alert boxes?

Here is a site where a test dialog can be invoked:
http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert


It is only possible to use the caption property of the Firefox alert box label to get the text in the dialog.

SilkTest Classic Example:

print(Desktop.Find("/BrowserApplication//Control[@role='dialog']//Control[@role='editable text']").getProperty("caption"))

Silk4J Example:

System.out.println(desktop.find("/BrowserApplication//Control[@role='dialog']//Control[@role='editable text']").getProperty("caption"));

Note: It is recommended to use a conditional statement to determine the browsertype the test is being executed against, and then deciding whether to use your existing script to get the text in Internet Explorer or using the above code for Firefox.