Search in sources :

Example 31 with HtmlElement

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

the class TestDriver method testFindElementsByNotExist.

/**
 * Tests NOT finding sub-elements of an HTMLElement
 * No exception should be raised but search should be done several times
 */
public void testFindElementsByNotExist() {
    SeleniumTestsContextManager.getThreadContext().setReplayTimeout(7);
    long start = new Date().getTime();
    Assert.assertEquals(new HtmlElement("", By.className("myClass")).findElements(By.id("foobarId")).size(), 0);
    Assert.assertTrue(new Date().getTime() - start > 6500);
}
Also used : HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) Date(java.util.Date)

Example 32 with HtmlElement

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

the class TestDriver method testFindElementsNotExist.

/**
 * Check that if no element is returned, no error is raised but we should have searched several times
 */
public void testFindElementsNotExist() {
    SeleniumTestsContextManager.getThreadContext().setReplayTimeout(7);
    long start = new Date().getTime();
    Assert.assertEquals(new HtmlElement("", By.name("foobar")).findElements().size(), 0);
    Assert.assertTrue(new Date().getTime() - start > 6500);
}
Also used : HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) Date(java.util.Date)

Example 33 with HtmlElement

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

the class TestDriver method testWebDriverWaitWithLowTimeout.

/**
 * issue #194: check that the WebDriverWait timeout is the one really applied
 */
public void testWebDriverWaitWithLowTimeout() {
    long start = new Date().getTime();
    try {
        new WebDriverWait(driver, 2).until(ExpectedConditions.visibilityOf(new HtmlElement("", By.id("someNonExistentId"))));
    } catch (TimeoutException e) {
    }
    // we cannot check precise timing as it depends on the hardware, but we should never wait more that 10 secs (the default timeout for searching element is 30 secs)
    Assert.assertTrue(new Date().getTime() - start < 10000);
}
Also used : HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) Date(java.util.Date) TimeoutException(org.openqa.selenium.TimeoutException)

Example 34 with HtmlElement

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

the class TestDriver method testFindHtmlElementsByWithSimilarElements.

/**
 * issue #314: check that we search element effectively inside the parent
 */
public void testFindHtmlElementsByWithSimilarElements() {
    List<WebElement> htmlElements = new HtmlElement("", By.id("parent")).findHtmlElements(By.tagName("div"));
    Assert.assertEquals(htmlElements.size(), 3);
    Assert.assertTrue(htmlElements.get(0) instanceof HtmlElement);
    Assert.assertEquals(htmlElements.get(0).getText(), "first child");
}
Also used : HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) WebElement(org.openqa.selenium.WebElement)

Example 35 with HtmlElement

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

the class TestDriver method testFindHtmlElementsBy.

/**
 * Tests finding sub-elements of an HTMLElement
 */
public void testFindHtmlElementsBy() {
    List<WebElement> htmlElements = new HtmlElement("", By.id("parent")).findHtmlElements(By.className("myClass"));
    Assert.assertEquals(htmlElements.size(), 2);
    Assert.assertTrue(htmlElements.get(0) instanceof HtmlElement);
    Assert.assertEquals(htmlElements.get(0).getText(), "first child");
}
Also used : HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) WebElement(org.openqa.selenium.WebElement)

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