Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
martingrossmann committed Jul 12, 2024
1 parent 7df9c10 commit c457ded
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ public enum Swipe {
DOWN;
}

// Relative positions to the screen dimension of standard swipe actions
// Relative start and end positions to the screen dimension of standard swipe actions
// for example scroll down:
// - 0.2 * screenHeight -> start y
// - 0.8 * screenHeight -> end y
// - x is center of screen
// - 0.2 * screenHeight -> start y (SCREEN_SWIPE_START)
// - 0.5 * screenHeight -> end y (SCREEN_MULTIPLIER)
// - x is center of screen
// for example scroll left:
// - 0.8 * screenWidth -> start x (SCREEN_SWIPE_END)
// - 0.5 * screenWidth -> end x (SCREEN_MULTIPLIER)
// - y is center of screen
private static final double SCREEN_SWIPE_START = 0.2;
private static final double SCREEN_SWIPE_END = 0.8;
private static final double SCREEN_MULTIPLIER = 0.5;

/**
* Run a shell command, especially at Android devices
Expand Down Expand Up @@ -152,13 +157,11 @@ private void swipeAction(WebDriver driver, Swipe direction, Point startPoint) {
AppiumDriver appiumDriver = this.getAppiumDriver(driver);
final Duration intensity = Duration.ofMillis(500);
// Length of swipe action according screen resolution
final double screenMultiplier = 0.5;


Dimension screenDim = appiumDriver.manage().window().getSize();
// final int centerX = screenDim.getWidth() / 2;
// final int centerY = screenDim.getHeight() / 2;
final int diffX = (int) (screenDim.getWidth() * screenMultiplier);
final int diffY = (int) (screenDim.getHeight() * screenMultiplier);
final int diffX = (int) (screenDim.getWidth() * SCREEN_MULTIPLIER);
final int diffY = (int) (screenDim.getHeight() * SCREEN_MULTIPLIER);

int startX = startPoint.getX();
int startY = startPoint.getY();
Expand Down

0 comments on commit c457ded

Please sign in to comment.