Search in sources :

Example 1 with ImageElement

use of com.seleniumtests.uipage.htmlelements.ImageElement in project seleniumRobot by bhecquet.

the class TestImageElement method testImageElement.

@Test(groups = { "ut" })
public void testImageElement() throws Exception {
    PowerMockito.mockStatic(WebUIDriver.class);
    Mockito.when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(driver);
    Mockito.when(driver.findElement(By.id("img"))).thenReturn(element);
    Mockito.when(driver.switchTo()).thenReturn(locator);
    Mockito.when(element.getSize()).thenReturn(new Dimension(10, 10));
    Mockito.when(element.getAttribute("src")).thenReturn("http://nowhere.com/jpg");
    ImageElement el = Mockito.spy(new ImageElement("image", By.id("img")));
    Assert.assertEquals(el.getHeight(), 10);
    Assert.assertEquals(el.getWidth(), 10);
    Assert.assertEquals(el.getUrl(), "http://nowhere.com/jpg");
    // check we called getDriver before using it
    PowerMockito.verifyPrivate(el, Mockito.times(3)).invoke("updateDriver");
}
Also used : ImageElement(com.seleniumtests.uipage.htmlelements.ImageElement) Dimension(org.openqa.selenium.Dimension) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with ImageElement

use of com.seleniumtests.uipage.htmlelements.ImageElement in project seleniumRobot by bhecquet.

the class TestFrameElement method testImageElementInsideFrame.

@Test(groups = { "ut" })
public void testImageElementInsideFrame() throws Exception {
    FrameElement frame = new FrameElement("", By.id("frameId"));
    ImageElement el = new ImageElement("", By.id("el"), frame);
    el.getWidth();
    verify(locator).frame(any(WebElement.class));
    verify(locator).defaultContent();
}
Also used : ImageElement(com.seleniumtests.uipage.htmlelements.ImageElement) FrameElement(com.seleniumtests.uipage.htmlelements.FrameElement) WebElement(org.openqa.selenium.WebElement) RemoteWebElement(org.openqa.selenium.remote.RemoteWebElement) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 3 with ImageElement

use of com.seleniumtests.uipage.htmlelements.ImageElement in project seleniumRobot by bhecquet.

the class TestFrameElement method testImageElementOutsideFrame.

@Test(groups = { "ut" })
public void testImageElementOutsideFrame() throws Exception {
    ImageElement el = new ImageElement("", By.id("el"));
    el.getWidth();
    verify(locator, times(0)).frame(any(WebElement.class));
}
Also used : ImageElement(com.seleniumtests.uipage.htmlelements.ImageElement) WebElement(org.openqa.selenium.WebElement) RemoteWebElement(org.openqa.selenium.remote.RemoteWebElement) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

MockitoTest (com.seleniumtests.MockitoTest)3 ImageElement (com.seleniumtests.uipage.htmlelements.ImageElement)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Test (org.testng.annotations.Test)3 WebElement (org.openqa.selenium.WebElement)2 RemoteWebElement (org.openqa.selenium.remote.RemoteWebElement)2 FrameElement (com.seleniumtests.uipage.htmlelements.FrameElement)1 Dimension (org.openqa.selenium.Dimension)1