public void invokeSelenium() { ISelenium selenium = (ISelenium)_seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { Assert.AreSame(selenium, javaSelenium.Selenium); } catch { Assert.Fail("The Selenium property test should not fail."); } } }
public void invokeDispose() { ISelenium selenium = (ISelenium)_seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { javaSelenium.Dispose(); } catch { Assert.Fail("The Dispose method should not fail."); } } }
public void invokeCallField() { ISelenium selenium = (ISelenium)_seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { javaSelenium.GetField("Field"); } catch { Assert.Fail("The GetField method should not fail."); } } }
public void invokeSeleniumStop() { _seleniumMock.Expect("Stop"); ISelenium selenium = (ISelenium)_seleniumMock.MockInstance; IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID); // don't wrap in using as this will cause Stop to be called TWICE. try { javaSelenium.Selenium.Stop(); } catch { Assert.Fail("Selenium.Stop should not fail."); } }
public void invokeSeleniumOpenURL() { string url = "http://nowhere.com"; _seleniumMock.Expect("Open", new object[] { url }); ISelenium selenium = (ISelenium)_seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { javaSelenium.Selenium.Open(url); } catch { Assert.Fail("Selenium.Open should not fail."); } } }
public void invokeWaitForPageLoad() { string seconds = "5000"; _seleniumMock.Expect("WaitForPageToLoad", new object[] { seconds }); ISelenium selenium = (ISelenium)_seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { javaSelenium.Selenium.WaitForPageToLoad(seconds); } catch { Assert.Fail("Selenium.WaitForPageToLoad should not fail."); } } }
public void invokeObjectID() { ISelenium selenium = (ISelenium)_seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { Assert.AreEqual(OBJECT_ID, javaSelenium.ObjectID, "The default ObjectID property did not match the specified value in the constructor"); string newObjectID = "anotherObject"; javaSelenium.ObjectID = newObjectID; Assert.AreEqual(newObjectID, javaSelenium.ObjectID, "The ObjectID property is not equal to the assigned value."); } catch { Assert.Fail("The ObjectID property test should not fail."); } } }
public void invokeSeleniumOpenURL() { string url = "http://nowhere.com"; _seleniumMock.Expect( "Open", new object[] {url} ); ISelenium selenium = (ISelenium) _seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { javaSelenium.Selenium.Open(url); } catch { Assert.Fail("Selenium.Open should not fail."); } } }
public void invokeSelenium() { ISelenium selenium = (ISelenium) _seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { Assert.AreSame(selenium, javaSelenium.Selenium); } catch { Assert.Fail("The Selenium property test should not fail."); } } }
public void invokeObjectID() { ISelenium selenium = (ISelenium) _seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { Assert.AreEqual(OBJECT_ID, javaSelenium.ObjectID, "The default ObjectID property did not match the specified value in the constructor"); string newObjectID = "anotherObject"; javaSelenium.ObjectID = newObjectID; Assert.AreEqual(newObjectID, javaSelenium.ObjectID, "The ObjectID property is not equal to the assigned value."); } catch { Assert.Fail("The ObjectID property test should not fail."); } } }
public void invokeDispose() { ISelenium selenium = (ISelenium) _seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { javaSelenium.Dispose(); } catch { Assert.Fail("The Dispose method should not fail."); } } }
public void invokeCallMethod() { ISelenium selenium = (ISelenium) _seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { javaSelenium.InvokeMethod("Method"); } catch { Assert.Fail("The InvokeMethod method should not fall."); } } }
// WARNING: This test runs extremely slow private void _GenericTestDialogFocus(string pBrowserString) { using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(HOST, PORT, pBrowserString, URL)) { _OpenPage(javaSelenium); javaSelenium.ObjectID = TABLE_APPLET_ID; JavaAction action = new JavaAction(javaSelenium); Table table = new Table("table"); Dialog dialog = new Dialog("dialog"); TabbedPane pane = new TabbedPane("ColorChooser.tabPane"); //System.Diagnostics.Debugger.Break(); Assert.AreEqual(action, action.Focus(table) .Select<Table>(new Cell(0, 1)) .Focus(dialog) // focuses on the actual dialog component .SetRootComponent(dialog) .Focus(pane) .Select<TabbedPane>("Swatches").Click() // subsequent calls inherit the RootComponent .Select<TabbedPane>("HSB").Click() .Select<TabbedPane>("RGB").Click() ); } }
public void invokeSeleniumStop() { _seleniumMock.Expect("Stop"); ISelenium selenium = (ISelenium) _seleniumMock.MockInstance; IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID); // don't wrap in using as this will cause Stop to be called TWICE. try { javaSelenium.Selenium.Stop(); } catch { Assert.Fail("Selenium.Stop should not fail."); } }
// WARNING: Broken private void _GenericTestSelectPopUp(string pBrowserString) { using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(HOST, PORT, pBrowserString, URL)) { _OpenPage(javaSelenium); javaSelenium.ObjectID = POPUP_APPLET_ID; JavaAction action = new JavaAction(javaSelenium); TextBox text = new TextBox("text"); //MenuItem item1 = new MenuItem("item1"); //MenuItem item2 = new MenuItem("item2"); action.ScrollBrowserWindowToBottom(); // WARNING: Must RightClick before the SelectPopup can be called. // This functionality is broken at the moment. There currently // is no way in FEST to specify a JPopupMenu directly Assert.AreEqual(action, action.Focus(text).RightClick().SelectPopUp()); //.RightClick().Select<MenuItem>(item1).Select<MenuItem>(item2) } }
private void _GenericTestSelect(string pBrowserString) { using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(HOST, PORT, pBrowserString, URL)) { javaSelenium.ObjectID = COMBO_APPLET_ID; _OpenPage(javaSelenium); JavaAction action = new JavaAction(javaSelenium); ComboBox box = new ComboBox("pattern").AddItem("dd.MM.yy"); Assert.AreEqual(action, action.Select(box)); javaSelenium.ObjectID = TABLE_APPLET_ID; action = new JavaAction(javaSelenium); // Alternative syntax for prespecifying selection items. //Table table = new Table("table").AddItems(new Cell(0, 0), new Cell(0,1), new Cell(0,2), new Cell(0,3), new Cell(0,4)); Table table = new Table("table"); Assert.AreEqual(action, action.Focus(table) .Select<Table>(new Cell(0,0)) // .Select<Table>(new Cell(0,1)) // this cell is avoided to prevent the popup dialog from hanging the test. .Select<Table>(new Cell(0,2)) .Select<Table>(new Cell(0,3)) .Select<Table>(new Cell(0,4)) ); } _GenericTestDialogFocus(pBrowserString); }
private void _GenericTestFocus(string pBrowserString) { using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(HOST, PORT, pBrowserString, URL)) { javaSelenium.ObjectID = TEST_APPLET_ID; _OpenPage(javaSelenium); JavaAction action = new JavaAction(javaSelenium); Assert.AreEqual(action, action.Focus()); javaSelenium.ObjectID = TABLE_APPLET_ID; action = new JavaAction(javaSelenium); Assert.AreEqual(action, action.Focus()); javaSelenium.ObjectID = TREE_APPLET_ID; action = new JavaAction(javaSelenium); Assert.AreEqual(action, action.Focus()); javaSelenium.ObjectID = COMBO_APPLET_ID; action = new JavaAction(javaSelenium); Assert.AreEqual(action, action.Focus()); javaSelenium.ObjectID = TAB_APPLET_ID; action = new JavaAction(javaSelenium); Assert.AreEqual(action, action.Focus()); javaSelenium.ObjectID = SPINNER_APPLET_ID; action = new JavaAction(javaSelenium); Assert.AreEqual(action, action.Focus()); javaSelenium.ObjectID = LIST_APPLET_ID; action = new JavaAction(javaSelenium); Assert.AreEqual(action, action.ScrollBrowserWindowToBottom()); Assert.AreEqual(action, action.Focus()); Button hire = new Button("hire"); Button fire = new Button("fire"); List employees = new List("employees"); TextBox employeeName = new TextBox("employeeName"); // WARNING : An illegal state exception will be thrown when attempting to focus on a disabled component //Assert.AreEqual(action, action.Focus(hire)); Assert.AreEqual(action, action.Focus(fire)); Assert.AreEqual(action, action.Focus(employees)); // Enter something in the employeeName text field to enable the hire button Assert.AreEqual(action, action.Focus(employeeName).Click().Type<TextBox>("New Guy")); Assert.AreEqual("New Guy", action.Focus(hire).Click().GetSelectedValue(employees)); Assert.AreEqual(1, action.GetSelectedValues(employees).Count); } }
public void invokeWaitForPageLoad() { string seconds = "5000"; _seleniumMock.Expect( "WaitForPageToLoad", new object[] { seconds} ); ISelenium selenium = (ISelenium) _seleniumMock.MockInstance; using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(selenium, OBJECT_ID)) { try { javaSelenium.Selenium.WaitForPageToLoad(seconds); } catch { Assert.Fail("Selenium.WaitForPageToLoad should not fail."); } } }
private void _GenericTestClick(string pBrowserString) { using (IJavaSelenium javaSelenium = new JavaSelenium.JavaSelenium(HOST, PORT, pBrowserString, URL)) { javaSelenium.ObjectID = TEST_APPLET_ID; _OpenPage(javaSelenium); JavaAction action = new JavaAction(javaSelenium); Button button = new Button("clickme"); Assert.AreEqual(action, action.Click(button)); javaSelenium.ObjectID = TREE_APPLET_ID; Tree tree = new Tree("tree"); action = new JavaAction(javaSelenium); Assert.AreEqual(action, action.Focus(tree).Select<Tree>("root").Click() .Select<Tree>("root/attribute1").Click() .Select<Tree>("root/attribute1/attribute1.1").Click() .Select<Tree>("root/attribute1/attribute1.3/leaf1.3.1").Click() .Select<Tree>("root/attribute1/attribute1.3/leaf1.3.2").Click() .Select<Tree>("root/attribute1/attribute1.3/leaf1.3.3").Click() .Select<Tree>("root/attribute2").Click() .Select<Tree>("root/attribute3").Click() ); javaSelenium.ObjectID = COMBO_APPLET_ID; ComboBox pattern = new ComboBox("pattern"); action = new JavaAction(javaSelenium); Assert.AreEqual(action, action.Focus(pattern) .Select<ComboBox>("yyyy.MMMMM.dd GGG hh:mm aaa") .Select<ComboBox>("K:mm a,z") .Select<ComboBox>("H:mm:ss:SSS") .Select<ComboBox>("h:mm a") .Select<ComboBox>("EEE, MMM d, ''yy") .Select<ComboBox>("yyy.MM.dd G 'at' hh:mm:ss z") .Select<ComboBox>("MM/dd/yy") ); javaSelenium.ObjectID = TAB_APPLET_ID; TabbedPane pane = new TabbedPane("pane"); action = new JavaAction(javaSelenium); Assert.AreEqual(action, action.Focus(pane) .Select<TabbedPane>("Tab 1").Click() .Select<TabbedPane>("Tab 2").Click() .Select<TabbedPane>("Tab 3").Click() .Select<TabbedPane>("Tab 4").Click() ); javaSelenium.ObjectID = SPINNER_APPLET_ID; Spinner month = new Spinner("month"); Spinner year = new Spinner("year"); Spinner date = new Spinner("date"); Assert.AreEqual(action, action .Focus(month).Click() .Focus(year).Click() .Focus(date).Click() ); } }