Skip to content

Commit

Permalink
Merge pull request #20 from alfa-laboratory/swipe_refact
Browse files Browse the repository at this point in the history
refactoring swipes
  • Loading branch information
JasperJhons committed Oct 17, 2017
2 parents 7265f86 + 696e3c6 commit 02cdc97
Showing 1 changed file with 26 additions and 43 deletions.
69 changes: 26 additions & 43 deletions src/main/java/ru/colibri/ui/steps/general/SwipeSteps.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,26 @@
//package ru.colibri.ui.steps.general;
//
//import io.appium.java_client.MobileElement;
//import io.appium.java_client.SwipeElementDirection;
//import org.jbehave.core.annotations.Named;
//import org.jbehave.core.annotations.When;
//import org.openqa.selenium.WebElement;
//import org.springframework.stereotype.Component;
//import ru.colibri.ui.core.steps.AbsSteps;
//import ru.yandex.qatools.allure.annotations.Step;
//
//@Component
//public class SwipeSteps extends AbsSteps {
// private static final int SWIPE_DURATION = 2000;
//
// @Step
// @When("вертикальный свайп \"$elementName\" вниз")
// public void swipingDown(@Named("$elementName") String elementName) {
// WebElement webElement = getWebElementByName(elementName);
// ((MobileElement) webElement).swipe(SwipeElementDirection.DOWN, 1, 1, SWIPE_DURATION);
// }
//
// @Step
// @When("вертикальный свайп \"$elementName\" вверх")
// public void swipingUp(@Named("$elementName") String elementName) {
// WebElement webElement = getWebElementByName(elementName);
// ((MobileElement) webElement).swipe(SwipeElementDirection.UP, 1, 1, SWIPE_DURATION);
// }
//
// @Step
// @When("горизонтальный свайп \"$elementName\" вправо")
// public void swipingRight(@Named("$elementName") String elementName) {
// WebElement webElement = getWebElementByName(elementName);
// ((MobileElement) webElement).swipe(SwipeElementDirection.RIGHT, 1, 1, SWIPE_DURATION);
// }
//
// @Step
// @When("горизонтальный свайп \"$elementName\" влево")
// public void swipingLeft(@Named("$elementName") String elementName) {
// WebElement webElement = getWebElementByName(elementName);
// ((MobileElement) webElement).swipe(SwipeElementDirection.LEFT, 1, 1, SWIPE_DURATION);
// }
//}
package ru.colibri.ui.steps.general;

import io.appium.java_client.TouchAction;
import org.openqa.selenium.WebElement;
import org.springframework.stereotype.Component;
import ru.colibri.ui.core.steps.AbsSteps;

import java.time.Duration;

@Component
public class SwipeSteps extends AbsSteps {


protected void verticalSwipe(String elementName, int swipeLength) {
WebElement webElement = getWebElementByName(elementName);
new TouchAction(driver).press(webElement).moveTo(0, swipeLength).release().perform();

}

protected void horizontalSwip(String elementName, int swipeLength, int duration) {
WebElement webElement = getWebElementByName(elementName);
new TouchAction(driver).press(webElement).waitAction(Duration.ofSeconds(duration)).
moveTo(swipeLength, 0).release().perform();
}

}

0 comments on commit 02cdc97

Please sign in to comment.