@Test public void testSetGUIDriver() throws Exception { ExtWebDriver otherwd = null; try { otherwd = SessionManager.getInstance().getNewSession(false); wd.open(url); otherwd.open(url); Element content = new Element(getDiv("content")); IInteractiveElement button = new Button(getButton("testWaitButton")); button.click(); content.waitForText(); String session1Str = content.getText(); content.setGUIDriver(otherwd); content.waitForElementPresent(); String session2Str = content.getText(); Assert.assertNotEquals( "Test that Element successfully switched sessions", session1Str, session2Str); } finally { if (otherwd != null) { otherwd.close(); SessionManager.getInstance().removeSession(otherwd); } } }
@Test public void testWaitForText() throws WidgetException { wd.open(url); IInteractiveElement clickButton = new Button(getButton("testWaitButton")); IElement element = new Element(getDiv("content")); clickButton.click(); element.waitForText(); }
@Test public void testWaitForAttributeNotEqualTo() throws WidgetException { wd.open(url); IInteractiveElement clickButton = new Button(getButton("attributeChanger")); IElement element = new Element(getDiv("content")); clickButton.click(); element.waitForAttributeNotEqualTo("randomAttrib", "Hello"); }
@Test public void testWaitForNotVisible() throws WidgetException { wd.open(url); IInteractiveElement clickButton = new Button(getButton("nonVisibilityTest")); IElement element = new Element(getButton("visibilityTest")); clickButton.click(); element.waitForNotVisible(); }
@Test public void testWaitForElementNotPresent() throws WidgetException { wd.open(url); IInteractiveElement clickButton = new Button(getButton("testWaitElementNotPresentButton")); IElement waitForElement = new Element(getSpan("someText")); clickButton.click(); waitForElement.waitForElementNotPresent(); }
@Test(expected = WidgetException.class) public void testWaitForElementPresentTimeout() throws WidgetException { wd.open(url); IInteractiveElement clickButton = new Button(getButton("testWaitButton")); IElement waitForElement = new Element(getSpan("failMe")); clickButton.click(); waitForElement.waitForElementPresent(); }
@Test public void testMouseMoveOut() throws WidgetException { wd.open(url); IInteractiveElement ie = new InteractiveElement(getDiv("dest")); IElement element = new Element(getDiv("content")); ie.waitForElementPresent(); ie.mouseMove(); ie.mouseMoveOut(); Assert.assertEquals("Mouse Moved Out", element.getText()); }
// Selenium issue #3604 @Test public void testDragAndDrop() throws WidgetException { wd.open(url); IInteractiveElement ie = new InteractiveElement(getDiv("draggableText")); IInteractiveElement destination = new InteractiveElement(getDiv("dropBox")); ie.waitForElementPresent(); destination.waitForElementPresent(); ie.dragAndDrop(destination); destination.waitForText(); Assert.assertEquals("dragged", destination.getText()); }