01: package watij;
02:
03: import static watij.finders.SymbolFactory.*;
04: import watij.runtime.UnknownObjectException;
05: import watij.dialogs.ModalDialog;
06:
07: public class ModalDialogTest extends WatijTestCase {
08:
09: protected void setUp() throws Exception {
10: super .setUp();
11: ie.goTo(HTML_ROOT + "modal_dialog_launcher.html");
12: ie.bringToFront();
13: }
14:
15: public void testModalDialog() throws Exception {
16: new Thread(new Runnable() {
17: public void run() {
18: try {
19: ie.button("Launch Dialog").click();
20: } catch (Exception e) {
21: e.printStackTrace();
22: }
23: }
24: }).start();
25: ModalDialog modalDialog = ie.modalDialog();
26: System.out
27: .println("modalDialog.html() = " + modalDialog.html());
28: modalDialog.textField(name, "modal_text").set("hello");
29: modalDialog.button(value, "Close").click();
30: assertEquals("hello", ie.textField(name, "modaloutput").value());
31: }
32:
33: public void testModalDialogWithFrames() throws Exception {
34: ie.textField(name, "modalpath").set("frame_buttons.html");
35: new Thread(new Runnable() {
36: public void run() {
37: try {
38: ie.button("Launch Dialog").click();
39: } catch (Exception e) {
40: e.printStackTrace();
41: }
42: }
43: }).start();
44: ModalDialog modalDialog = ie.modalDialog();
45: assertTrue(modalDialog.frame("buttonFrame").button(caption,
46: "Click Me").enabled());
47: try {
48: modalDialog.button(caption, "Disabled Button").enabled();
49: fail("Did not throw UnknownObjectException");
50: } catch (UnknownObjectException e) {
51: }
52: modalDialog.close();
53: assertEquals("undefined", ie.textField(name, "modaloutput")
54: .value());
55: }
56: }
|