Open Jacobvu84 opened 5 years ago
package com.asksqa.interactions;
import io.appium.java_client.touch.offset.PointOption;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Interaction;
public class TapOnPoint extends AppiumObject implements Interaction{
private PointOption point;
public TapOnPoint(PointOption point) {
this.point = point;
}
@Override
public <T extends Actor> void performAs(T actor) {
withAction(actor).tap(point).perform();
}
}
E.g:
Tap.on(PointOption.point(200, 200))
package com.asksqa.interactions;
import static net.serenitybdd.screenplay.Tasks.instrumented;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Interaction;
import net.serenitybdd.screenplay.targets.Target;
import net.thucydides.core.annotations.Step;
import io.appium.java_client.touch.offset.PointOption;
public class TapOutSide extends AndroidObject implements Interaction {
private static final Logger LOGGER = LoggerFactory.getLogger(TapOutSide.class);
private Target target;
public TapOutSide(Target target) {
this.target = target;
}
@Override
@Step("{0} taps outside the pop-up screen")
public <T extends Actor> void performAs(T actor) {
int x = target.resolveFor(actor).getRect().x;
int y = target.resolveFor(actor).getRect().y;
int h = target.resolveFor(actor).getRect().height;
int w = target.resolveFor(actor).getRect().width;
LOGGER.info("Tap at: (" + x +"," + y + ")");
withAction(actor).tap(PointOption.point(x + w + 60, y + h + 100)).perform();
}
public static Interaction on(Target target) {
return instrumented(TapOutSide.class, target);
}
}
E.g
Tap.outSide(POP_UP_CONTAINER)