Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BookMyShow Assignment Implementation #68

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions caps/capabilities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"android": {
"platformName": "android",
"platformVersion": "11.0",
"automationName": "UiAutomator2",
"autoGrantPermissions": true,
"appPackage": "com.appiumpro.the_app",
"uiautomator2ServerInstallTimeout": 10000,
"adbExecTimeout": 15000,
"eventTimings": true,
"enablePerformanceLogging": true,
"printPageSourceOnFindFailure": true,
"app": {
"local": "./temp/sampleApps/TheApp-release.apk"
},
"deviceName": "android",
"noSign": true
},
"hostMachines": [
{
"machineIP": "127.0.0.1"
}
]
}
20 changes: 20 additions & 0 deletions configs/BookMyShow_config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
RUNNER=distribute
FRAMEWORK=cucumber
RUNNER_LEVEL=methods
CAPS=./caps/capabilities.json
APPLITOOLS_CONFIGURATION=./configs/applitools_config.json
BASE_URL_FOR_WEB=BOOKMYSHOW_BASE_URL
BROWSER=chrome
ENVIRONMENT_CONFIG_FILE=./src/test/resources/environments.json
IS_VISUAL=false
LOG_DIR=target
LOG_PROPERTIES_FILE=./src/test/resources/log4j.properties
PARALLEL=1
PLATFORM=web
REPORT_PORTAL_FILE=src/test/resources/reportportal.properties
RUN_IN_CI=false
TARGET_ENVIRONMENT=prod
TEST_DATA_FILE=./src/test/resources/testData.json
MAX_NUMBER_OF_APPIUM_DRIVERS=5
MAX_NUMBER_OF_WEB_DRIVERS=5
BROWSER_CONFIG_FILE=./configs/browser_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.znsio.sample.e2e.businessLayer.bookMyShow;

import com.context.TestExecutionContext;
import com.znsio.sample.e2e.entities.bookMyShow.BOOKMYSHOW_SAMPLE_TEST_CONTEXT;
import com.znsio.sample.e2e.screen.bookMyShow.BookMyShowLoginPageScreen;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Runner;
import org.assertj.core.api.SoftAssertions;
import static org.assertj.core.api.Assertions.assertThat;

public class BookMyShowHomePageBL {
private final TestExecutionContext context;
private final SoftAssertions softly;
private final String currentUserPersona;
private final Platform currentPlatform;

public BookMyShowHomePageBL(String userPersona, Platform forPlatform) {
long threadId = Thread.currentThread()
.getId();
this.context = Runner.getTestExecutionContext(threadId);
softly = Runner.getSoftAssertion(threadId);
this.currentUserPersona = userPersona;
this.currentPlatform = forPlatform;
Runner.setCurrentDriverForUser(userPersona, forPlatform, context);
}

public BookMyShowHomePageBL() {
long threadId = Thread.currentThread()
.getId();
this.context = Runner.getTestExecutionContext(threadId);
softly = Runner.getSoftAssertion(threadId);
this.currentUserPersona = BOOKMYSHOW_SAMPLE_TEST_CONTEXT.ME;
this.currentPlatform = Runner.getPlatform();
}

public BookMyShowHomePageBL launchBookMyShowHomePage() {
boolean isBookMyShowHomepageLaunched = BookMyShowLoginPageScreen.get().isBookMyShowHomepageLaunched();
assertThat(isBookMyShowHomepageLaunched).as(String.format("BookMyShow Home Page Not Launched")).isTrue();
return this;
}

public BookMyShowHomePageBL setLocationAsDelhi(String cityName) {
boolean locationAsDelhi = BookMyShowLoginPageScreen.get().isLocationDelhi(cityName);
softly.assertThat(locationAsDelhi).as(String.format("Location is not set as: "+cityName)).isTrue();
boolean isValidLogin = (boolean) BookMyShowLoginPageScreen.get().isValidLogin();
assertThat(isValidLogin).as(String.format("Not a valid Login")).isTrue();
return this;
}

public MoviePageBL goToMoviesPage() {
BookMyShowLoginPageScreen.get().moviesPage();
return new MoviePageBL();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.znsio.sample.e2e.businessLayer.bookMyShow;

import com.context.TestExecutionContext;
import com.znsio.sample.e2e.entities.bookMyShow.BOOKMYSHOW_SAMPLE_TEST_CONTEXT;
import com.znsio.sample.e2e.screen.bookMyShow.BookingPageScreen;
import com.znsio.sample.e2e.screen.bookMyShow.SelectedDateScreen;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Runner;
import org.assertj.core.api.SoftAssertions;

public class BookingPageBL {
private final TestExecutionContext context;
private final SoftAssertions softly;
private final String currentUserPersona;
private final Platform currentPlatform;

public BookingPageBL() {
long threadId = Thread.currentThread()
.getId();
this.context = Runner.getTestExecutionContext(threadId);
softly = Runner.getSoftAssertion(threadId);
this.currentUserPersona = BOOKMYSHOW_SAMPLE_TEST_CONTEXT.ME;
this.currentPlatform = Runner.getPlatform();
}

public SelectedMovieBL selectDateAfterTomorrow(String secondMovieTitle) {
boolean onCorrectBookingPage = BookingPageScreen.get().bookingForSelectedMovie(secondMovieTitle);
softly.assertThat(onCorrectBookingPage).as(String.format("Mismatch in Movie Details on Movie Landing Page")).isTrue();
SelectedDateScreen.get().selectExpectedDate();
return new SelectedMovieBL();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.znsio.sample.e2e.businessLayer.bookMyShow;

import com.context.TestExecutionContext;
import com.znsio.sample.e2e.entities.bookMyShow.BOOKMYSHOW_SAMPLE_TEST_CONTEXT;
import com.znsio.sample.e2e.screen.bookMyShow.CinemaHallScreen;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Runner;
import org.assertj.core.api.SoftAssertions;

public class CinemaHallBL {
private final TestExecutionContext context;
private final SoftAssertions softly;
private final String currentUserPersona;
private final Platform currentPlatform;

public CinemaHallBL() {
long threadId = Thread.currentThread()
.getId();
this.context = Runner.getTestExecutionContext(threadId);
softly = Runner.getSoftAssertion(threadId);
this.currentUserPersona = BOOKMYSHOW_SAMPLE_TEST_CONTEXT.ME;
this.currentPlatform = Runner.getPlatform();
}

public CinemaHallBL userSelectsSecondSlot(String cinemaHallTitle) {
CinemaHallScreen.get().selectSecondSlot(cinemaHallTitle);
return new CinemaHallBL();
}

public SeatSelectionBL userSelectsNumberOfPeople(int numberOfSeats) {
CinemaHallScreen.get().selectNumberOfPeople(numberOfSeats);
return new SeatSelectionBL();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.znsio.sample.e2e.businessLayer.bookMyShow;

import com.context.TestExecutionContext;
import com.znsio.sample.e2e.entities.bookMyShow.BOOKMYSHOW_SAMPLE_TEST_CONTEXT;
import com.znsio.sample.e2e.screen.bookMyShow.MovieLandingPageScreen;
import com.znsio.sample.e2e.screen.bookMyShow.MoviesListPageScreen;
import com.znsio.sample.e2e.screen.bookMyShow.MoviesPageScreen;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Runner;
import org.assertj.core.api.SoftAssertions;
import org.openqa.selenium.WebElement;

import java.util.List;

public class MovieLandingPageBL {
private final TestExecutionContext context;
private final SoftAssertions softly;
private final String currentUserPersona;
private final Platform currentPlatform;

public MovieLandingPageBL() {
long threadId = Thread.currentThread()
.getId();
this.context = Runner.getTestExecutionContext(threadId);
softly = Runner.getSoftAssertion(threadId);
this.currentUserPersona = BOOKMYSHOW_SAMPLE_TEST_CONTEXT.ME;
this.currentPlatform = Runner.getPlatform();
}

public BookingPageBL selectScreenType() {
MoviesPageScreen.get().userSelectsScreen();
return new BookingPageBL();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.znsio.sample.e2e.businessLayer.bookMyShow;

import com.context.TestExecutionContext;
import com.znsio.sample.e2e.entities.bookMyShow.BOOKMYSHOW_SAMPLE_TEST_CONTEXT;
import com.znsio.sample.e2e.screen.bookMyShow.MovieLandingPageScreen;
import com.znsio.sample.e2e.screen.bookMyShow.MoviesListPageScreen;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Runner;
import org.assertj.core.api.SoftAssertions;
import org.openqa.selenium.WebElement;

import java.util.List;

public class MoviePageBL {
private final TestExecutionContext context;
private final SoftAssertions softly;
private final String currentUserPersona;
private final Platform currentPlatform;

public MoviePageBL() {
long threadId = Thread.currentThread()
.getId();
this.context = Runner.getTestExecutionContext(threadId);
softly = Runner.getSoftAssertion(threadId);
this.currentUserPersona = BOOKMYSHOW_SAMPLE_TEST_CONTEXT.ME;
this.currentPlatform = Runner.getPlatform();
}

public MovieLandingPageBL userOpenSecondMovie(int moviePosition) {
List<WebElement> movieslist = MoviesListPageScreen.get().getNowShowingMoviewList();
String secondMovieTitle = MoviesListPageScreen.get().getSecondMovieTittle(movieslist);
context.addTestState(BOOKMYSHOW_SAMPLE_TEST_CONTEXT.SECOND_MOVIE_TITLE, secondMovieTitle);
MoviesListPageScreen.get().userSelectsSecondMovie(movieslist, moviePosition);
boolean isMovieTitleCorrect = MovieLandingPageScreen.get().isMovieTitleCorrect(secondMovieTitle);
softly.assertThat(isMovieTitleCorrect).as(String.format("Mismatch in Movie Details on Movie Landing Page")).isTrue();
return new MovieLandingPageBL();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.znsio.sample.e2e.businessLayer.bookMyShow;

import com.context.TestExecutionContext;
import com.znsio.sample.e2e.entities.bookMyShow.BOOKMYSHOW_SAMPLE_TEST_CONTEXT;
import com.znsio.sample.e2e.screen.bookMyShow.SeatSelectionScreen;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Runner;
import org.assertj.core.api.SoftAssertions;
import static org.junit.Assert.assertFalse;

public class SeatSelectionBL {
private final TestExecutionContext context;
private final SoftAssertions softly;
private final String currentUserPersona;
private final Platform currentPlatform;

public SeatSelectionBL() {
long threadId = Thread.currentThread()
.getId();
this.context = Runner.getTestExecutionContext(threadId);
softly = Runner.getSoftAssertion(threadId);
this.currentUserPersona = BOOKMYSHOW_SAMPLE_TEST_CONTEXT.ME;
this.currentPlatform = Runner.getPlatform();
}

public void checkAvailabilityOfSeats(int percentage) {
boolean seatAvailability = SeatSelectionScreen.get().checkSeatAvailability(percentage);
assertFalse("Less than 10% seats are available", seatAvailability);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.znsio.sample.e2e.businessLayer.bookMyShow;

import com.context.TestExecutionContext;
import com.znsio.sample.e2e.entities.bookMyShow.BOOKMYSHOW_SAMPLE_TEST_CONTEXT;
import com.znsio.sample.e2e.screen.bookMyShow.CinemaHallScreen;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Runner;
import org.assertj.core.api.SoftAssertions;

public class SelectedMovieBL {
private final TestExecutionContext context;
private final SoftAssertions softly;
private final String currentUserPersona;
private final Platform currentPlatform;

public SelectedMovieBL() {
long threadId = Thread.currentThread()
.getId();
this.context = Runner.getTestExecutionContext(threadId);
softly = Runner.getSoftAssertion(threadId);
this.currentUserPersona = BOOKMYSHOW_SAMPLE_TEST_CONTEXT.ME;
this.currentPlatform = Runner.getPlatform();
}

public CinemaHallBL selectThirdHall() {
CinemaHallScreen.get().selectTheThirdHall();
return new CinemaHallBL();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.znsio.sample.e2e.entities.bookMyShow;

import com.znsio.teswiz.entities.TEST_CONTEXT;

public class BOOKMYSHOW_SAMPLE_TEST_CONTEXT extends TEST_CONTEXT {
public static final String ME = "me";
public static final String MOVIES_LIST = "moviesList";
public static final String SECOND_MOVIE_TITLE = "secondMovieTitle";
public static final String THIRD_HALL_TITLE = "thirdHallTitle";
public static final String MOBILE_NUMBER = "9910792362";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.znsio.sample.e2e.exceptions.bookMyShow;

public class bookMyShowException extends RuntimeException {
public bookMyShowException(String message) {
super(message);
}

public bookMyShowException(String message, Exception e) {
super(message, e);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.znsio.sample.e2e.exceptions.bookMyShow;

public class continueButtonNotEnabledException extends Throwable {
public continueButtonNotEnabledException(String message) {
super(message);
}

public continueButtonNotEnabledException(String message, Exception e) {
super(message, e);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.znsio.sample.e2e.screen.bookMyShow;

import com.znsio.sample.e2e.screen.web.bookMyShow.BookMyShowLoginPageScreenWeb;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Driver;
import com.znsio.teswiz.runner.Drivers;
import com.znsio.teswiz.runner.Runner;
import com.znsio.teswiz.runner.Visual;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.log4j.Logger;

public abstract class BookMyShowLoginPageScreen {
private static final String SCREEN_NAME = BookMyShowLoginPageScreen.class.getSimpleName();
private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME);

public static BookMyShowLoginPageScreen get() {
Driver driver = Drivers.getDriverForCurrentUser(Thread.currentThread().getId());
Platform platform = Runner.fetchPlatform(Thread.currentThread()
.getId());
LOGGER.info(SCREEN_NAME + ": Driver type: " + driver.getType() + ": Platform: " + platform);
Visual visually = Drivers.getVisualDriverForCurrentUser(Thread.currentThread().getId());

switch (platform) {
case web:
return new BookMyShowLoginPageScreenWeb(driver, visually);
}
throw new NotImplementedException(SCREEN_NAME + " is not implemented in " + Runner.getPlatform());
}


public abstract boolean isBookMyShowHomepageLaunched();

public abstract boolean isLocationDelhi(String cityName);

public abstract Object isValidLogin();

public abstract MoviesListPageScreen moviesPage();
}
Loading