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

Bms assignment yatharth #55

Open
wants to merge 9 commits 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
35 changes: 35 additions & 0 deletions caps/bms_local_capabilities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"android": {
"adbExecTimeout": 45000,
"app": {
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/ajio-8-3-4.apk"
},
"appActivity": "com.ril.ajio.launch.activity.SplashScreenActivity",
"appPackage": "com.ril.ajio",
"appWaitDuration": 45000,
"automationName": "UiAutomator2",
"autoGrantPermissions": true,
"deviceName": "android",
"dontStopAppOnReset": true,
"enablePerformanceLogging": true,
"eventTimings": true,
"newCommandTimeout": 12000,
"noSign": true,
"platformName": "android",
"platformVersion": "11.0",
"printPageSourceOnFindFailure": true,
"skipUnlock": true,
"noReset": false
},
"hostMachines": [
{
"machineIP": "127.0.0.1",
"simulators": [
{
"deviceName": "iPhone 11",
"OS": "13.5"
}
]
}
]
}
23 changes: 23 additions & 0 deletions configs/bms_local_config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
RUNNER=distribute
FRAMEWORK=cucumber
RUNNER_LEVEL=methods
CAPS=./caps/bms_local_capabilities.json
APP_NAME=AJIO
APP_PACKAGE_NAME=com.ril.ajio
APPLITOOLS_CONFIGURATION=./configs/applitools_config.json
BASE_URL_FOR_WEB=BMS_BASE_URL
BROWSER=firefox
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=android
PROXY_KEY=HTTP_PROXY
REPORT_PORTAL_FILE=src/test/resources/reportportal.properties
RUN_IN_CI=false
TARGET_ENVIRONMENT=prod
LAUNCH_NAME_SUFFIX= on 'prod' Environment
TEST_DATA_FILE=./src/test/resources/testData.json
CLEANUP_DEVICE_BEFORE_STARTING_EXECUTION=false
BROWSER_CONFIG_FILE=./configs/browser_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.znsio.sample.e2e.businessLayer.bms;

import com.context.TestExecutionContext;
import com.znsio.sample.e2e.entities.SAMPLE_TEST_CONTEXT;
import com.znsio.sample.e2e.screen.bms.BMSHomeScreen;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Runner;
import org.apache.log4j.Logger;
import org.assertj.core.api.SoftAssertions;

public class BMSHomeBL {

private static final Logger LOGGER = Logger.getLogger(BMSHomeBL.class.getName());
private final TestExecutionContext context;
private final SoftAssertions softly;
private final String currentUserPersona;
private final Platform currentPlatform;

public BMSHomeBL(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 BMSHomeBL loginAsGuestUserForGivenLocation(String location) {
BMSHomeScreen.get().searchForLocation(location);
return this;
}

public BMSMoviesBL selectMovieCategory() {
BMSHomeScreen.get().selectMoviesCategory();
return new BMSMoviesBL();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.znsio.sample.e2e.businessLayer.bms;

import com.context.TestExecutionContext;
import com.znsio.sample.e2e.entities.SAMPLE_TEST_CONTEXT;
import com.znsio.sample.e2e.screen.bms.BMSHomeScreen;
import com.znsio.sample.e2e.screen.bms.BMSMoviesScreen;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Runner;
import org.apache.log4j.Logger;
import org.assertj.core.api.SoftAssertions;

public class BMSMoviesBL {

private static final Logger LOGGER = Logger.getLogger(BMSHomeBL.class.getName());
private final TestExecutionContext context;
private final SoftAssertions softly;
private final String currentUserPersona;
private final Platform currentPlatform;

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

public BMSMoviesBL selectMovie(String moviePosition) {
BMSMoviesScreen.get().selectMovieAtPosition(moviePosition);
return this;
}

public BMSMoviesBL selectDateAfter2Days() {

BMSMoviesScreen.get().selectDateAfterTwoDays();
return this;
}

public BMSMoviesBL selectSecondLastTimeSlotForCinemaHallAtPosition(String cinemaPosition) {

BMSMoviesScreen.get().selectSecondLastTimeSlotForMovie(cinemaPosition);
return this;
}

public BMSSelectSeatsBL selectNoOfSeats(String noOfSeats) {

BMSMoviesScreen.get().selectNoOfSeatsToBook(noOfSeats);
return new BMSSelectSeatsBL();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.znsio.sample.e2e.businessLayer.bms;

import com.context.TestExecutionContext;
import com.znsio.sample.e2e.entities.SAMPLE_TEST_CONTEXT;
import com.znsio.sample.e2e.screen.bms.BMSSelectSeatsScreen;
import com.znsio.teswiz.entities.Platform;
import com.znsio.teswiz.runner.Runner;
import org.apache.log4j.Logger;
import org.assertj.core.api.SoftAssertions;
import org.junit.Assert;

public class BMSSelectSeatsBL {

private static final Logger LOGGER = Logger.getLogger(BMSHomeBL.class.getName());
private final TestExecutionContext context;
private final SoftAssertions softly;
private final String currentUserPersona;
private final Platform currentPlatform;

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

public BMSSelectSeatsBL validateAvailableSeatsPercentage(String validationPercentage) {

int totalAvailableSeats = BMSSelectSeatsScreen.get().getTotalAvailableSeats();
int totalSeats = BMSSelectSeatsScreen.get().getTotalSeats();

double validatePercent = Double.parseDouble(validationPercentage);
LOGGER.info("Vacant seats should be greater than " + validatePercent + " %");
double actualPercentageOfVacantSeats = (totalAvailableSeats/totalSeats)*100;
LOGGER.info("Actual vacant seats are " + actualPercentageOfVacantSeats + " %");

softly.assertThat(actualPercentageOfVacantSeats).as("Actual vacant seat percentage is lower than Validation percentage").isGreaterThan(validatePercent);
//Assert.assertTrue("No of vacant seats is less than " + validatePercent + " %", actualPercentageOfVacantSeats>validatePercent);

return this;
}
}
37 changes: 37 additions & 0 deletions src/test/java/com/znsio/sample/e2e/screen/bms/BMSHomeScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.znsio.sample.e2e.screen.bms;

import com.znsio.sample.e2e.screen.web.bms.BMSHomeScreenWeb;
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.lang.NotImplementedException;

import java.util.logging.Logger;

public abstract class BMSHomeScreen {

private static final String SCREEN_NAME = BMSHomeScreen.class.getSimpleName();
private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME);

public static BMSHomeScreen 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 android:
// return new AjioHomeScreenAndroid(driver, visually);
case web:
return new BMSHomeScreenWeb(driver, visually);
}
throw new NotImplementedException(
SCREEN_NAME + " is not implemented in " + Runner.getPlatform());
}

public abstract BMSHomeScreen searchForLocation(String location);

public abstract BMSMoviesScreen selectMoviesCategory();
}
42 changes: 42 additions & 0 deletions src/test/java/com/znsio/sample/e2e/screen/bms/BMSMoviesScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.znsio.sample.e2e.screen.bms;

import com.znsio.sample.e2e.screen.web.bms.BMSMoviesScreenWeb;
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.lang.NotImplementedException;

import java.util.logging.Logger;

public abstract class BMSMoviesScreen {

private static final String SCREEN_NAME = BMSMoviesScreen.class.getSimpleName();
private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME);

public static BMSMoviesScreen 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 android:
// return new AjioHomeScreenAndroid(driver, visually);
case web:
return new BMSMoviesScreenWeb(driver, visually);
}
throw new NotImplementedException(
SCREEN_NAME + " is not implemented in " + Runner.getPlatform());
}


public abstract BMSMoviesScreen selectMovieAtPosition(String moviePosition);

public abstract BMSMoviesScreen selectDateAfterTwoDays();

public abstract BMSMoviesScreen selectSecondLastTimeSlotForMovie(String cinemaPosition);

public abstract BMSSelectSeatsScreen selectNoOfSeatsToBook(String noOfSeats);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.znsio.sample.e2e.screen.bms;

import com.znsio.sample.e2e.screen.web.bms.BMSSelectSeatsScreenWeb;
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.lang.NotImplementedException;

import java.util.logging.Logger;

public abstract class BMSSelectSeatsScreen {

private static final String SCREEN_NAME = BMSSelectSeatsScreen.class.getSimpleName();
private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME);

public static BMSSelectSeatsScreen 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 android:
// return new AjioHomeScreenAndroid(driver, visually);
case web:
return new BMSSelectSeatsScreenWeb(driver, visually);
}
throw new NotImplementedException(
SCREEN_NAME + " is not implemented in " + Runner.getPlatform());
}


public abstract int getTotalAvailableSeats();

public abstract int getTotalSeats();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.znsio.sample.e2e.screen.web.bms;

import com.znsio.sample.e2e.screen.bms.BMSHomeScreen;
import com.znsio.sample.e2e.screen.bms.BMSMoviesScreen;
import com.znsio.sample.e2e.screen.web.jiomeet.InAMeetingScreenWeb;
import com.znsio.teswiz.runner.Driver;
import com.znsio.teswiz.runner.Visual;
import org.apache.log4j.Logger;
import org.openqa.selenium.By;

public class BMSHomeScreenWeb extends BMSHomeScreen {

private static final String SCREEN_NAME = InAMeetingScreenWeb.class.getSimpleName();
private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME);
private final Driver driver;
private final Visual visually;

private final By bySearchBarXpath = By.xpath("//input[@placeholder = 'Search for your city']");

private final By byMoviesTabXpath = By.xpath("//a[text()='Movies']");

public BMSHomeScreenWeb(Driver driver, Visual visually) {
this.driver = driver;
this.visually = visually;
}


public BMSHomeScreen searchForLocation(String location) {

LOGGER.info("Location to be searched is " + location);
driver.waitTillElementIsPresent(bySearchBarXpath).sendKeys(location);
visually.takeScreenshot(SCREEN_NAME,"BMS Homepage");
driver.waitTillElementIsVisible(By.xpath("//strong[text()='"+location+"']")).click();
LOGGER.info(location + " searched and clicked");

return this;
}

@Override
public BMSMoviesScreen selectMoviesCategory() {

LOGGER.info("Selecting MOVIES tab");
driver.waitTillElementIsPresent(byMoviesTabXpath).click();
LOGGER.info("Movies tab selected successfully");

return BMSMoviesScreen.get();
}

}
Loading