-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from alfa-laboratory/swipe_refact
refactoring swipes
- Loading branch information
Showing
1 changed file
with
26 additions
and
43 deletions.
There are no files selected for viewing
69 changes: 26 additions & 43 deletions
69
src/main/java/ru/colibri/ui/steps/general/SwipeSteps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |