Search in sources :

Example 1 with FrameElement

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

the class SeleniumNativeActions method recordFrameSwitch.

/**
 * Method interceptFindHtmlElement creates an HtmlElement from findElement, but does not handle frames.
 * Here, we record all switchTo().frame(WebElement) call to create a FrameElement chain
 * @param joinPoint
 * @return
 * @throws Throwable
 */
@Around(// caller is a PageObject
"this(com.seleniumtests.uipage.PageObject) && " + "(call(public * org.openqa.selenium.support.ui.ExpectedConditions.frameToBeAvailableAndSwitchToIt (..))" + ")")
public Object recordFrameSwitch(ProceedingJoinPoint joinPoint) throws Throwable {
    if (Boolean.TRUE.equals(doOverride())) {
        Object frameArg = joinPoint.getArgs()[0];
        FrameElement frameEl = getFrameElement(frameArg);
        if (frameEl == null) {
            return joinPoint.proceed(joinPoint.getArgs());
        }
        if (getCurrentFrame() == null) {
            setCurrentFrame(frameEl);
        } else {
            frameEl.setFrameElement(getCurrentFrame());
            setCurrentFrame(frameEl);
        }
        return new ExpectedCondition<WebDriver>() {

            @Override
            public WebDriver apply(WebDriver driver) {
                try {
                    return driver;
                } catch (NoSuchFrameException e) {
                    return null;
                }
            }

            @Override
            public String toString() {
                return "frame to be available: " + frameArg;
            }
        };
    } else {
        return joinPoint.proceed(joinPoint.getArgs());
    }
}
Also used : WebDriver(org.openqa.selenium.WebDriver) NoSuchFrameException(org.openqa.selenium.NoSuchFrameException) FrameElement(com.seleniumtests.uipage.htmlelements.FrameElement) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) Around(org.aspectj.lang.annotation.Around)

Example 2 with FrameElement

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

the class TestFrameElement method testLinkElementInsideFrame.

@Test(groups = { "ut" })
public void testLinkElementInsideFrame() throws Exception {
    FrameElement frame = new FrameElement("", By.id("frameId"));
    LinkElement el = new LinkElement("", By.id("el"), frame);
    el.click();
    verify(locator).frame(any(WebElement.class));
    verify(locator).defaultContent();
}
Also used : 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 3 with FrameElement

use of com.seleniumtests.uipage.htmlelements.FrameElement 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 4 with FrameElement

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

the class TestFrameElement method testButtonElementInsideFrame.

/* tests for each element defined in framework */
/**
 * check we switched to default content and frame
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testButtonElementInsideFrame() throws Exception {
    FrameElement frame = new FrameElement("", By.id("frameId"));
    ButtonElement el = new ButtonElement("", By.id("el"), frame);
    el.submit();
    verify(locator).frame(any(WebElement.class));
    verify(locator).defaultContent();
}
Also used : ButtonElement(com.seleniumtests.uipage.htmlelements.ButtonElement) RadioButtonElement(com.seleniumtests.uipage.htmlelements.RadioButtonElement) 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 5 with FrameElement

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

the class TestFrameElement method testTextFieldElementInsideFrame.

@Test(groups = { "ut" })
public void testTextFieldElementInsideFrame() throws Exception {
    FrameElement frame = new FrameElement("", By.id("frameId"));
    TextFieldElement el = new TextFieldElement("", By.id("el"), frame);
    el.sendKeys("toto");
    verify(locator).frame(any(WebElement.class));
    verify(locator).defaultContent();
}
Also used : TextFieldElement(com.seleniumtests.uipage.htmlelements.TextFieldElement) 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)

Aggregations

FrameElement (com.seleniumtests.uipage.htmlelements.FrameElement)19 MockitoTest (com.seleniumtests.MockitoTest)16 WebElement (org.openqa.selenium.WebElement)16 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)16 Test (org.testng.annotations.Test)16 RemoteWebElement (org.openqa.selenium.remote.RemoteWebElement)15 HtmlElement (com.seleniumtests.uipage.htmlelements.HtmlElement)8 LinkElement (com.seleniumtests.uipage.htmlelements.LinkElement)2 RadioButtonElement (com.seleniumtests.uipage.htmlelements.RadioButtonElement)2 Around (org.aspectj.lang.annotation.Around)2 By (org.openqa.selenium.By)2 WebDriverException (org.openqa.selenium.WebDriverException)2 SeleniumTestsContextManager (com.seleniumtests.core.SeleniumTestsContextManager)1 TestStepManager (com.seleniumtests.core.TestStepManager)1 ScenarioException (com.seleniumtests.customexception.ScenarioException)1 BrowserType (com.seleniumtests.driver.BrowserType)1 CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)1 DriverConfig (com.seleniumtests.driver.DriverConfig)1 DriverExceptionListener (com.seleniumtests.driver.DriverExceptionListener)1 TestType (com.seleniumtests.driver.TestType)1