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");
}
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();
}
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));
}
Aggregations