Skip to content

Commit

Permalink
Horizontal swipe with gesture Plugin (#238)
Browse files Browse the repository at this point in the history
* Added logic to get browser version of chrome in local

* Added get browser version logic for chrome and safari

* Added implementation to get browser version in container

* Added version variable in build.gradle

* disabled run in CI

* added constants for path and indentation

* Removed chrome options set binary path

* Removed local browser version fetch methods

* Removed docker terminal command approach for browser version fetching

* Removed imports not used

* Added scenario for horizontalswipe test

* Added BL and screen methods

* Added implementation to open the product

* Added scroll for category

* Added check for ad on screen

* Added implementation for horizontal swipe with Jio cinema

* Removing ajio implementation

* Updated app path and method names

* updated method names

* Added the direction from Direction class

* updated scenario and app path

* Updated Steps method name

* Replaced string direction by Direction object
  • Loading branch information
Darshan3S authored Jul 7, 2023
1 parent dd4ca2a commit 96f7de8
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/znsio/teswiz/entities/Direction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

public enum Direction {
UP("up"),
DOWN("down");
DOWN("down"),
LEFT("left"),
RIGHT("right");
private final String direction;

Direction(String direction) {
Expand Down
15 changes: 14 additions & 1 deletion src/main/java/com/znsio/teswiz/runner/Driver.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.znsio.teswiz.entities.Direction;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.exceptions.FileNotUploadedException;
import com.znsio.teswiz.exceptions.InvalidTestDataException;
import io.appium.java_client.AppiumBy;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.HidesKeyboard;
Expand All @@ -26,6 +27,7 @@
import org.openqa.selenium.interactions.Pause;
import org.openqa.selenium.interactions.PointerInput;
import org.openqa.selenium.interactions.Sequence;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

Expand All @@ -37,6 +39,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.Map;


import static com.znsio.teswiz.tools.Wait.waitFor;
Expand Down Expand Up @@ -604,7 +607,6 @@ public void doubleTap(WebElement element) {
appiumDriver.perform(Arrays.asList(clickPosition));
}


public void flick() {
AppiumDriver appiumDriver = (AppiumDriver) this.driver;
Dimension screenSize = driver.manage().window().getSize();
Expand All @@ -625,4 +627,15 @@ public void flick() {

appiumDriver.perform(Arrays.asList(flick));
}

public void horizontalSwipeWithGesture(WebElement element, Direction direction) {
RemoteWebElement remoteWebElement = (RemoteWebElement) element;
if ((direction.equals(Direction.LEFT)) || direction.equals(Direction.RIGHT)) {
((JavascriptExecutor) driver).executeScript("mobile: swipeGesture", Map.of("elementId", remoteWebElement.getId(),
"direction", direction.toString(),
"percent", 1,
"speed", 80
));
} else throw new InvalidTestDataException("Invalid Direction");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.znsio.teswiz.businessLayer.jiocinema;

import com.context.TestExecutionContext;
import com.znsio.teswiz.entities.Direction;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Runner;
import com.znsio.teswiz.screen.jiocinema.JioCinemaScreen;
Expand Down Expand Up @@ -40,6 +41,11 @@ public JioCinemaBL scrollTillTrendingInIndiaSection() {
return this;
}

public JioCinemaBL swipeMovieTrendingInIndiaSection(Direction direction, int movieNumberOnScreen) {
JioCinemaScreen.get().swipeTrendingItem(direction, movieNumberOnScreen);
return this;
}

public JioCinemaBL verifyMovieNumberVisibleOnScreen(int movieNumberOnScreen) {
LOGGER.info("verifying movie number visible on trending in india screen after swipe");
assertThat(JioCinemaScreen.get().isMovieNumberVisibleOnScreen(movieNumberOnScreen))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

import com.applitools.eyes.MatchLevel;
import com.applitools.eyes.appium.Target;
import com.znsio.teswiz.entities.Direction;
import com.znsio.teswiz.runner.Driver;
import com.znsio.teswiz.runner.Visual;
import com.znsio.teswiz.screen.jiocinema.JioCinemaScreen;
import io.appium.java_client.AppiumBy;
import org.apache.log4j.Logger;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public class JioCinemaScreenAndroid extends JioCinemaScreen {
private static final Logger LOGGER = Logger.getLogger(JioCinemaScreenAndroid.class.getName());
private final Driver driver;
private final Visual visually;
private final String SCREEN_NAME = JioCinemaScreenAndroid.class.getSimpleName();
private final String visibleMovieNumberXpath = "//android.widget.TextView[@text='%s']";
private final String movieXpath = "//android.widget.TextView[@text='%s']//parent::android.view.View";

public JioCinemaScreenAndroid(Driver driver, Visual visually) {
this.driver = driver;
Expand Down Expand Up @@ -49,4 +53,13 @@ public boolean isMovieNumberVisibleOnScreen(int movieNumberOnScreen) {
Target.region(AppiumBy.xpath(String.format(visibleMovieNumberXpath, movieNumberOnScreen))));
return isMovieVisibleOnScreen;
}

@Override
public JioCinemaScreen swipeTrendingItem(Direction direction, int movieNumberOnScreen) {
LOGGER.info(String.format("Swiping %s movie number : %s ", direction, movieNumberOnScreen));
WebElement movieTrending = driver.waitTillElementIsVisible(
By.xpath(String.format(movieXpath, movieNumberOnScreen)));
driver.horizontalSwipeWithGesture(movieTrending, direction);
return this;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.znsio.teswiz.screen.jiocinema;

import com.znsio.teswiz.entities.Direction;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Driver;
import com.znsio.teswiz.runner.Drivers;
Expand Down Expand Up @@ -34,4 +35,7 @@ public static JioCinemaScreen get() {
public abstract JioCinemaScreen scrollTillTrendingInIndiaSection();

public abstract boolean isMovieNumberVisibleOnScreen(int movieNumberOnScreen);

public abstract JioCinemaScreen swipeTrendingItem(Direction direction, int movieNumberOnScreen);

}
7 changes: 7 additions & 0 deletions src/test/java/com/znsio/teswiz/steps/JioCinemaSteps.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.context.SessionContext;
import com.context.TestExecutionContext;
import com.znsio.teswiz.businessLayer.jiocinema.JioCinemaBL;
import com.znsio.teswiz.entities.Direction;
import com.znsio.teswiz.entities.SAMPLE_TEST_CONTEXT;
import com.znsio.teswiz.runner.Drivers;
import com.znsio.teswiz.runner.Runner;
Expand Down Expand Up @@ -40,4 +41,10 @@ public void iSwipeLeftOnTrendingInIndiaSection() {
public void iAmAbleToViewNumberTrendingCinema(int movieNumberOnScreen) {
new JioCinemaBL(SAMPLE_TEST_CONTEXT.ME, Runner.getPlatform()).verifyMovieNumberVisibleOnScreen(movieNumberOnScreen);
}

@When("I swipe {string} trending no {int} on trending in india section")
public void iSwipeTrendingNoOnTrendingInIndiaSection(String direction, int movieNumberOnScreen) {
new JioCinemaBL(SAMPLE_TEST_CONTEXT.ME, Runner.getPlatform())
.swipeMovieTrendingInIndiaSection(Direction.valueOf(direction.toUpperCase()),movieNumberOnScreen);
}
}
11 changes: 10 additions & 1 deletion src/test/resources/com/znsio/teswiz/features/jioCinema.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,13 @@ Feature: jio cinema test
When I swipe left on tending in india section
Then I am able to view number 3 trending movie
When I swipe right on tending in india section
Then I am able to view number 1 trending movie
Then I am able to view number 1 trending movie

# CONFIG=./configs/jiocinema_local_config.properties PLATFORM=android TAG=horizontalSwipeUsingGesturePluginTest ./gradlew run
@android @swipe @horizontalSwipeUsingGesturePluginTest
Scenario: validating horizontal swipe with gesture functionality
Given I navigate to jio Cinema application's home page
When I swipe "left" trending no 2 on trending in india section
Then I am able to view number 3 trending movie
When I swipe "right" trending no 2 on trending in india section
Then I am able to view number 1 trending movie

0 comments on commit 96f7de8

Please sign in to comment.