> Does anyone have any code samples for interacting with javascript
> alerts and prompt boxes? TIA.
Code using alerts is all throughout the test code. I use it extensively
when testing new javascript features.
If all you want to do it track alerts to make sure they happened, you
can collect them into a CollectingAlertHandler like this.
final List collectedAlerts = new ArrayList();
webClient.setAlertHandler(new
CollectingAlertHandler(collectedAlerts));
All the messages will be put into the list as they happen. I use this
all the time when testing.
If you want to actually do something when the alert happens then create
a class that implements AlertHandler and pass it in.
Prompts are handled like this
webClient.setPromptHandler( new PromptHandler() {
public String handlePrompt( final Page page, final String
message ) {
// do something
return "Flintstone";
}
} );
Hope this helps.
--
Mike Bowler
Principal, Gargoyle Software Inc.
Voice: (416) 822-0973 | Email : mb...@Ga...
Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com
|