Search in sources :

Example 16 with HtmlElement

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

the class TestPageObject2 method testCaptureElementSnapshotWithCheck.

/**
 * Capture element snapshot and sends it to selenium server
 *
 * @throws IOException
 */
@Test(groups = { "ut" })
public void testCaptureElementSnapshotWithCheck() throws IOException {
    page.setScreenshotUtil(screenshotUtil);
    String htmlFilePath = page.getHtmlFilePath();
    page.captureElementSnapshot("img", new HtmlElement("", By.id("el")), SnapshotCheckType.TRUE);
    // check capture has been done on the second call (a first capture is done at
    // PageObject init)
    Assert.assertFalse(page.getHtmlFilePath().equals(htmlFilePath));
    // check scroll delay is 0 by default
    verify(screenshotUtil).capture(any(SnapshotTarget.class), eq(ScreenShot.class), eq(0));
}
Also used : SnapshotTarget(com.seleniumtests.driver.screenshots.SnapshotTarget) HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 17 with HtmlElement

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

the class TestFrameElement method testUseElementInsideElementInsideFrame.

/**
 * Test that we enter the iframe of the parent element when searching looking a sub-element
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testUseElementInsideElementInsideFrame() throws Exception {
    FrameElement frame = new FrameElement("", By.id("frameId"));
    HtmlElement el = new HtmlElement("", By.id("el"), frame);
    LinkElement link = el.findLinkElement(By.id("link"));
    link.click();
    verify(locator).frame(any(WebElement.class));
    verify(locator).defaultContent();
}
Also used : HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) LinkElement(com.seleniumtests.uipage.htmlelements.LinkElement) 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 18 with HtmlElement

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

the class TestFrameElement method testUseElementOutsideFrame.

@Test(groups = { "ut" })
public void testUseElementOutsideFrame() throws Exception {
    HtmlElement el = new HtmlElement("", By.id("el"));
    el.click();
    verify(locator, times(0)).frame(any(WebElement.class));
}
Also used : HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) 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 19 with HtmlElement

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

the class TestFrameElement method testUseElementInside2Frames.

@Test(groups = { "ut" })
public void testUseElementInside2Frames() throws Exception {
    FrameElement frame = new FrameElement("", By.id("frameId"));
    FrameElement frame2 = new FrameElement("", By.id("frameId2"), frame);
    HtmlElement el = new HtmlElement("", By.id("el"), frame2);
    el.click();
    // switch to each frame
    verify(locator, times(2)).frame(any(WebElement.class));
    verify(locator).defaultContent();
}
Also used : HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) 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 20 with HtmlElement

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

the class TestHtmlElement method testElementNotFoundLowTimeout.

@Test(groups = { "ut" })
public void testElementNotFoundLowTimeout() throws Exception {
    HtmlElement elNotPresent2 = new HtmlElement("element", By.id("notPresent"), (Integer) null, 5);
    when(driver.findElement(By.id("notPresent"))).thenThrow(new NoSuchElementException("Unable to locate element with ID: 'notPresent'"));
    LocalDateTime start = LocalDateTime.now();
    try {
        elNotPresent2.getValue();
    } catch (WebDriverException e) {
    }
    Assert.assertTrue(LocalDateTime.now().minusSeconds(6).isBefore(start));
    Assert.assertTrue(LocalDateTime.now().minusSeconds(4).isAfter(start));
}
Also used : LocalDateTime(java.time.LocalDateTime) HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) WebDriverException(org.openqa.selenium.WebDriverException) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

HtmlElement (com.seleniumtests.uipage.htmlelements.HtmlElement)50 WebElement (org.openqa.selenium.WebElement)24 Test (org.testng.annotations.Test)23 MockitoTest (com.seleniumtests.MockitoTest)22 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)22 RemoteWebElement (org.openqa.selenium.remote.RemoteWebElement)12 ScenarioException (com.seleniumtests.customexception.ScenarioException)10 LinkElement (com.seleniumtests.uipage.htmlelements.LinkElement)10 CheckBoxElement (com.seleniumtests.uipage.htmlelements.CheckBoxElement)9 Element (com.seleniumtests.uipage.htmlelements.Element)9 GenericPictureElement (com.seleniumtests.uipage.htmlelements.GenericPictureElement)9 RadioButtonElement (com.seleniumtests.uipage.htmlelements.RadioButtonElement)9 TimeoutException (org.openqa.selenium.TimeoutException)9 FrameElement (com.seleniumtests.uipage.htmlelements.FrameElement)8 LocalDateTime (java.time.LocalDateTime)8 NoSuchElementException (org.openqa.selenium.NoSuchElementException)8 Date (java.util.Date)5 WebDriverException (org.openqa.selenium.WebDriverException)5 Field (java.lang.reflect.Field)4 ScreenShot (com.seleniumtests.driver.screenshots.ScreenShot)3