use of com.seleniumtests.uipage.htmlelements.FrameElement 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.FrameElement 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();
}
use of com.seleniumtests.uipage.htmlelements.FrameElement in project seleniumRobot by bhecquet.
the class SeleniumNativeActions method getFrameElement.
/**
* Returns a FrameElement based on the object passed in argument
* @param frameArg
* @return
* @throws SecurityException
* @throws NoSuchFieldException
* @throws IllegalAccessException
* @throws IllegalArgumentException
*/
private FrameElement getFrameElement(Object frameArg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
FrameElement frameEl = null;
if (frameArg instanceof HtmlElement) {
frameEl = new FrameElement("", ((HtmlElement) frameArg).getBy());
} else if (frameArg instanceof WebElement && frameArg.getClass().getName().contains("Proxy")) {
LocatingElementHandler locatingEh = (LocatingElementHandler) Proxy.getInvocationHandler(frameArg);
Field locatorField = LocatingElementHandler.class.getDeclaredField("locator");
locatorField.setAccessible(true);
DefaultElementLocator locator = ((DefaultElementLocator) locatorField.get(locatingEh));
Field byField = DefaultElementLocator.class.getDeclaredField("by");
byField.setAccessible(true);
frameEl = new FrameElement("", (By) byField.get(locator));
} else if (frameArg instanceof By) {
frameEl = new FrameElement("", (By) frameArg);
} else if (frameArg instanceof Integer) {
frameEl = new FrameElement("", By.tagName("iframe"), (Integer) frameArg);
} else if (frameArg instanceof String) {
String name = ((String) frameArg).replaceAll("(['\"\\\\#.:;,!?+<>=~*^$|%&@`{}\\-/\\[\\]\\(\\)])", "\\\\$1");
frameEl = new FrameElement("", By.cssSelector("frame[name='" + name + "'],iframe[name='" + name + "'],frame#" + name + ",iframe#" + name));
}
return frameEl;
}
use of com.seleniumtests.uipage.htmlelements.FrameElement in project seleniumRobot by bhecquet.
the class SeleniumNativeActions method recordSwitchToFramCalls.
/**
* 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.WebDriver.TargetLocator+.frame (..))" + ")")
public Object recordSwitchToFramCalls(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 null;
} else {
return joinPoint.proceed(joinPoint.getArgs());
}
}
use of com.seleniumtests.uipage.htmlelements.FrameElement in project seleniumRobot by bhecquet.
the class TestFrameElement method testTableInsideFrame.
@Test(groups = { "ut" })
public void testTableInsideFrame() throws Exception {
FrameElement frame = new FrameElement("", By.id("frameId"));
Table el = new Table("", By.id("el"), frame);
el.getColumns();
// issue #320: as we return HtmlElement instead of WebElement, we need to search for root element (the table) each time we search for columns and cells
verify(locator, times(3)).frame(any(WebElement.class));
verify(locator, times(3)).defaultContent();
}
Aggregations