use of com.seleniumtests.uipage.ReplayOnError in project seleniumRobot by bhecquet.
the class HtmlElement method pinch.
@ReplayOnError(waitAfterAction = true)
public void pinch() {
PerformsTouchActions performTouchActions = checkForMobile();
MobileElement mobElement = (MobileElement) getUnderlyingElement(getRealElementNoSearch());
// code taken from appium
MultiTouchAction multiTouch = new MultiTouchAction(performTouchActions);
Point upperLeft = mobElement.getLocation();
Point center = mobElement.getCenter();
int yOffset = center.getY() - upperLeft.getY();
TouchAction<?> action0 = createTouchAction().press(ElementOption.element(mobElement, center.getX(), center.getY() - yOffset)).moveTo(ElementOption.element(mobElement)).release();
TouchAction<?> action1 = createTouchAction().press(ElementOption.element(mobElement, center.getX(), center.getY() + yOffset)).moveTo(ElementOption.element(mobElement)).release();
multiTouch.add(action0).add(action1).perform();
}
use of com.seleniumtests.uipage.ReplayOnError in project seleniumRobot by bhecquet.
the class HtmlElement method waitForPresent.
/**
* Wait element to present using Explicit Waits with timeout in seconds. This
* method is used for special element which needs long time to present. This
* method is replayed because it may fail if frame is not present at start. The
* replay is not done if TimeOutException raises (see ReplayAction class)
*
* @param timeout timeout in seconds. Set a minimal value of 1 sec to avoid not
* searching for element
*/
@ReplayOnError
public void waitForPresent(int timeout) {
// refresh driver
setDriver(updateDriver());
try {
setImplicitWaitTimeout(510, TimeUnit.MILLISECONDS);
Clock clock = Clock.systemUTC();
Instant end = clock.instant().plusSeconds(Math.max(1, timeout));
while (end.isAfter(clock.instant())) {
try {
WebElement elt = new WebDriverWait(getDriver(), 0).ignoring(ConfigurationException.class, ScenarioException.class).until(ExpectedConditionsC.presenceOfElementLocated(this));
outlineElement(elt);
return;
} catch (TimeoutException e) {
// nothing to do
}
}
throw new TimeoutException("Element is not present", new NoSuchElementException(toString()));
} finally {
setImplicitWaitTimeout(SeleniumTestsContextManager.getThreadContext().getImplicitWaitTimeout());
}
}
use of com.seleniumtests.uipage.ReplayOnError in project seleniumRobot by bhecquet.
the class HtmlElement method zoom.
@ReplayOnError(waitAfterAction = true)
public void zoom() {
PerformsTouchActions performTouchActions = checkForMobile();
MobileElement mobElement = (MobileElement) getUnderlyingElement(getRealElementNoSearch());
MultiTouchAction multiTouch = new MultiTouchAction(performTouchActions);
Point upperLeft = mobElement.getLocation();
Point center = mobElement.getCenter();
int yOffset = center.getY() - upperLeft.getY();
TouchAction<?> action0 = createTouchAction().press(PointOption.point(center.getX(), center.getY())).moveTo(ElementOption.element(mobElement, center.getX(), center.getY() - yOffset)).release();
TouchAction<?> action1 = createTouchAction().press(PointOption.point(center.getX(), center.getY())).moveTo(ElementOption.element(mobElement, center.getX(), center.getY() + yOffset)).release();
multiTouch.add(action0).add(action1).perform();
}
use of com.seleniumtests.uipage.ReplayOnError in project seleniumRobot by bhecquet.
the class HtmlElement method swipe.
/**
* Convenience method for swiping on the given element to the given direction
*
* @param xOffset X offset from the top-left corner of the element
* @param yOffset Y offset from the top-left corner of the element
* @param xMove Movement amplitude on x axis
* @param yMove Movement amplitude on y axis
*/
@ReplayOnError(waitAfterAction = true)
public void swipe(int xOffset, int yOffset, int xMove, int yMove) {
MobileElement mobElement = (MobileElement) getUnderlyingElement(getRealElementNoSearch());
createTouchAction().press(ElementOption.element(mobElement, xOffset, yOffset)).waitAction().moveTo(ElementOption.element(mobElement, xMove, yMove)).release().perform();
}
use of com.seleniumtests.uipage.ReplayOnError in project seleniumRobot by bhecquet.
the class PictureElement method clickAt.
/**
* Click at the coordinates xOffset, yOffset of the center of the found picture. Use negative offset to click on the left or
* top of the picture center
* In case the size ratio between searched picture and found picture is not 1, then, offset is
* the source offset so that it's compatible with any screen size and resolution
*/
@ReplayOnError(replayDelayMs = 1000, waitAfterAction = true)
public void clickAt(int xOffset, int yOffset) {
findElement();
Point intoElementPos = intoElement.getCoordinates().onPage();
int relativeX = detectedObjectRectangle.x + detectedObjectRectangle.width / 2 - intoElementPos.x;
int relativeY = detectedObjectRectangle.y + detectedObjectRectangle.height / 2 - intoElementPos.y;
moveAndClick(intoElement, relativeX + (int) (xOffset * pictureSizeRatio), relativeY + (int) (yOffset * pictureSizeRatio));
}
Aggregations