@Test(expected = WidgetException.class) public void testHasTextException() throws WidgetException { wd.open(url); IElement element = new Element(getDiv("zzzzcontent")); element.hasText("Here"); }
@Test public void testHasTextTrue() throws WidgetException { wd.open(url); IElement element = new Element(getDiv("removeContent")); Assert.assertTrue("Test that hasText returns true", element.hasText("some")); }
@Test(expected = WidgetException.class) public void testGetTextException() throws WidgetException { wd.open(url); IElement element = new Element(getSpan("INVALIDsomeText")); element.getText(); }
@Test(expected = WidgetException.class) public void testIsAttributePresentException() throws WidgetException { wd.open(url); IElement element = new Element(getDiv("myContent")); element.isAttributePresent("randomAttrib"); }
@Test(expected = WidgetException.class) public void testWaitForNotVisibleException() throws WidgetException { wd.open(url); IElement element = new Element(getButton("visibilityTest")); element.waitForNotVisible(); }
@Test public void testGetLocator() throws WidgetException { wd.open(url); String test = "//DIV[@id='this_is_my_locator']"; IElement e = new Element(test); Assert.assertEquals("Test get locator should return the value passed in", test, e.getLocator()); }
@Test public void testGetInnerHtml() throws WidgetException { wd.open(url); IElement e = new Element("someText"); String html = e.getInnerHTML(); Assert.assertEquals("Here is some text", html); }
@Test public void testIsElementPresentTrue() throws WidgetException { wd.open(url); IElement e = new Element(button); Assert.assertTrue( "Test isElementPresent on an element that does exist returns true", e.isElementPresent()); }
@Test(expected = WidgetException.class) public void testWaitForAttributeNotEqualToException() throws WidgetException { wd.open(url); IElement element = new Element(getDiv("content")); element.waitForAttributeNotEqualTo("randomAttrib", "Hello"); }
@Test public void testIsAttributePresentFalse() throws WidgetException { wd.open(url); IElement element = new Element(getDiv("content")); Assert.assertFalse( "Test isAttributePresent returns false", element.isAttributePresent("someAttribute")); }
@Test public void testIsAttributePresentTrue() throws WidgetException { wd.open(url); IElement element = new Element(getDiv("content")); Assert.assertTrue( "Test isAttributePresent returns true", element.isAttributePresent("randomAttrib")); }
@Test public void testGetText() throws WidgetException { wd.open(url); IElement element = new Element(getSpan("someText")); String exp = "Here is some text"; Assert.assertEquals(exp, element.getText()); }
@Test(expected = WidgetException.class) public void testWaitForElementNotPresentTimeout() throws WidgetException { wd.open(url); IElement waitForElement = new Element(getSpan("someText")); waitForElement.waitForElementNotPresent(); }
@Test public void testIsElementVisibleTimeoutTrue() throws WidgetException { wd.open(url); IElement hidden = new Element(button); Assert.assertTrue( "Testing isElementVisible on a hidden button should be return false", hidden.isElementVisible(500)); }
@Test public void testIsElementVisibleFalse() throws WidgetException { wd.open(url); IElement hidden = new Element(invisibleButton); Assert.assertFalse( "Testing isElementVisible on a non-hidden button should be return true", hidden.isElementVisible()); }
@Test public void testIsElementNotPresentTimeoutFalse() throws WidgetException { wd.open(url); IElement e = new Element(button); Assert.assertFalse( "Test isElementPresent on an element that does not exist returns false", e.isElementNotPresent(500)); }
@Test public void testGetChildNodesValuesText() throws WidgetException { wd.open(url); IElement e = new Element("inner1"); String[] actual = e.getChildNodesValuesText(); String[] expected = new String[] {"hello world", "welcome"}; Assert.assertArrayEquals(expected, actual); }
@Test(expected = WidgetException.class) public void testGetLocationYException() throws WidgetException { wd.open(url); IElement element = new Element(getButton("zzztestWaitButton")); int val = -1; val = element.getLocationY(); Assert.assertNotEquals(-1, val); }
@Test public void testGetLocationY() throws WidgetException { wd.open(url); IElement element = new Element(getButton("testWaitButton")); int val = -1; val = element.getLocationY(); Assert.assertNotEquals("Test that getLocationY returned an int value", -1, val); }
@Test public void testIsElementPresentFalse() throws WidgetException { wd.open(url); String test = "//button[@id='myButtonDoesntExist']"; IElement e = new Element(test); Assert.assertFalse( "Test isElementPresent on an element that doesn't exist returns false", e.isElementPresent()); }
@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(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 testWaitForElementNotPresent() throws WidgetException { wd.open(url); IInteractiveElement clickButton = new Button(getButton("testWaitElementNotPresentButton")); IElement waitForElement = new Element(getSpan("someText")); clickButton.click(); waitForElement.waitForElementNotPresent(); }
@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(expected = WidgetException.class) public void testGetCssValueException() throws WidgetException { wd.open(url); IElement element = new Element(getButton("zzzmyInvisibleButton")); Assert.assertEquals( "Test that getCssValue returns the correct attribute", "hidden", element.getCssValue("visibility")); }
@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 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()); }
@Test public void testGetAttribute() throws WidgetException { wd.open(url); IElement element = new Element(getDiv("content")); String expected = "Hello"; Assert.assertEquals( "Test getAttribute returns expected string", expected, element.getAttribute("randomAttrib")); }
@Test public void testCSSSelector2() throws WidgetException { wd.open(url); IElement e = new Element("#removeContent>span"); Assert.assertEquals("Here is some text", e.getText()); }
@Test public void testCSSSelector() throws WidgetException { wd.open(url); IElement e = new Element("#myButton"); Assert.assertEquals("Click me", e.getText()); }