Search in sources :

Example 36 with HtmlElement

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

the class TestDriver method testFindHtmlElementsByNotExist.

/**
 * Tests NOT finding sub-elements of an HTMLElement
 * No exception should be raised but search should be done several times
 */
public void testFindHtmlElementsByNotExist() {
    SeleniumTestsContextManager.getThreadContext().setReplayTimeout(7);
    long start = new Date().getTime();
    Assert.assertEquals(new HtmlElement("", By.className("myClass")).findHtmlElements(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 37 with HtmlElement

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

the class TestDriver method testFindHtmlElementsByInsideFrame.

/**
 * Tests finding sub-elements of an HTMLElement inside frame
 * issue #314: search for an element into iframe. Search sub-elements of this element.
 * 				We search in the second table because the bug relies in the fact that findHtmlElements do return elements which do not correspond the the elements returned
 * 				by a simple driver.findElements(By.tagname('a'))
 */
public void testFindHtmlElementsByInsideFrame() {
    List<WebElement> htmlElements = new HtmlElement("", By.id("tableIframe2"), DriverTestPage.iframe).findHtmlElements(By.tagName("td"));
    Assert.assertEquals(htmlElements.size(), 2);
    Assert.assertTrue(htmlElements.get(0) instanceof HtmlElement);
    Assert.assertEquals(htmlElements.get(0).getText(), "Value 3");
}
Also used : HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) WebElement(org.openqa.selenium.WebElement)

Example 38 with HtmlElement

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

the class DriverTestPageWithoutFixedPattern method move.

public void move() {
    CustomEventFiringWebDriver driver = (CustomEventFiringWebDriver) (getDriver());
    HtmlElement html = new HtmlElement("", By.tagName("html"));
    driver.manage().window().getPosition();
    driver.manage().window().getSize();
    driver.getViewPortDimensionWithoutScrollbar();
    new Actions(driver).moveToElement(html).moveByOffset(10, 100).click().perform();
    driver.getCurrentUrl();
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Actions(org.openqa.selenium.interactions.Actions) HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement)

Example 39 with HtmlElement

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

the class TestByC method testByOrWithPlatformSpecificLocator.

/**
 * Test specific locator with non mobile platform. No element should be found
 */
@Test(groups = { "it" }, expectedExceptions = NoSuchElementException.class)
public void testByOrWithPlatformSpecificLocator() {
    SeleniumTestsContextManager.getThreadContext().setReplayTimeout(3);
    new HtmlElement("or", ByC.or(android(By.id("text2")))).getTagName();
}
Also used : HtmlElement(com.seleniumtests.uipage.htmlelements.HtmlElement) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 40 with HtmlElement

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

the class TestFrameElement method testUseElementInsideFrameRetryOnError.

@Test(groups = { "ut" })
public void testUseElementInsideFrameRetryOnError() throws Exception {
    FrameElement frame = new FrameElement("", By.id("frameId"));
    HtmlElement el = new HtmlElement("", By.id("el"), frame);
    Mockito.doThrow(new WebDriverException("fake exception")).doNothing().when(element).click();
    el.click();
    // 2 invocations because first call to click raises an error
    verify(locator, times(2)).frame(any(WebElement.class));
    verify(locator, times(2)).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) WebDriverException(org.openqa.selenium.WebDriverException) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

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