From b2aedd2dc209bd43a11d3001784de7c765eb9ccb Mon Sep 17 00:00:00 2001 From: Aliaksej Mialeshka Date: Fri, 7 Jun 2024 14:18:18 +0200 Subject: [PATCH] mfc updates --- AI/mfc/automation/base/BaseTest.java | 68 ++++--------- AI/mfc/automation/base/ICollectablesTest.java | 98 ++++++++++--------- AI/mfc/automation/screens/LobbyScreen.java | 10 +- .../collectables/CollectablesAlbumScreen.java | 10 +- .../collectables/CollectablesCardsScreen.java | 35 ++++--- .../collectables/ItemsDetailsScreen.java | 2 +- .../collectables/SetCompletedScreen.java | 16 +-- .../collectables/TotalProgressScreen.java | 4 +- .../screens/collectables/TradeScreen.java | 6 +- .../screens/views/OrbRewardsView.java | 7 +- .../CollectablesMainTutorialView.java | 2 +- .../CollectablesTradingTutorialView.java | 2 +- AI/mfc/automation/steps/ui/LobbySteps.java | 6 +- .../collectables/CollectablesAlbumSteps.java | 59 ++++++----- .../collectables/CollectablesCardsSteps.java | 7 +- .../TotalProgressScreenSteps.java | 5 + .../ui/randomrewards/OrbRewardsSteps.java | 4 +- .../randomrewards/OrbTotalRewardsSteps.java | 8 +- 18 files changed, 178 insertions(+), 171 deletions(-) diff --git a/AI/mfc/automation/base/BaseTest.java b/AI/mfc/automation/base/BaseTest.java index 0a06e59..4f31fe7 100644 --- a/AI/mfc/automation/base/BaseTest.java +++ b/AI/mfc/automation/base/BaseTest.java @@ -20,6 +20,7 @@ import com.myproject.automation.enums.config.TestrailProperty; import com.myproject.automation.exceptions.PMEnvironmentException; import com.myproject.automation.exceptions.PMException; +import com.myproject.automation.listeners.TestRailFilterListener; import com.myproject.automation.models.DeviceConfig; import com.myproject.automation.models.application.User; import com.myproject.automation.models.pojo.Device; @@ -85,8 +86,6 @@ public abstract class BaseTest extends BaseSteps implements ITest, IConfigurable private boolean isBeforePass = false; @Getter private ThreadLocal currentTestParametersAsString = new InheritableThreadLocal<>(); - private static List deviceConfigList = new ArrayList<>(); - private static List devicesWithIssuesList = new ArrayList<>(); static { if (AutomationDriver.isHeadSpinMultipleDeviceLimit() || !DeviceManager.getHeadSpinPredefinedDevices().isEmpty()) { @@ -95,10 +94,6 @@ public abstract class BaseTest extends BaseSteps implements ITest, IConfigurable AutomationDriver.connectToHeadSpinDevicesAndUpdateJsonFile(); reinstallAppForHsAvailableDevices(); } - //List of all DeviceConfig for later redistribution to avoid skipped tests due to device issues - for (Device device : DeviceManager.getAllAvailableDevices()) { - deviceConfigList.add(getDeviceConfig(device)); - } } @Override @@ -115,7 +110,6 @@ public void run(IConfigureCallBack callBack, ITestResult testResult) { break; } releasePort(testResult); - changeUnavailableDevice(testResult); callBack.runConfigurationMethod(testResult); } } @@ -154,10 +148,6 @@ public void beforeMethod(Object[] objects, ITestResult iTestResult) { deviceConfig.getDeviceName(), deviceConfig.getUdid())); iTestResult.getMethod().setRetryAnalyzerClass(PMRetryAnalyzer.class); try { - if (devicesWithIssuesList.stream().anyMatch(device -> device.getUdid().equals(this.deviceConfig.getUdid()))) { - Logger.get().info(String.format("Device with issue %s. The device configuration will be changed", this.deviceConfig.getUdid())); - changeDeviceConfig(); - } AppSteps.get().init(this.deviceConfig.getUdid(), deviceConfig); AppSteps.get().dismissAlertIfPresent(); SocketDriver.initLogsBuilder(); @@ -322,9 +312,24 @@ public Object[] factory(XmlTest test) { Collections.shuffle(devices); for (Device activeDevice : devices) { BaseTest testClass = this.getClass().getDeclaredConstructor().newInstance(); - if (testMethodsToInclude.stream().anyMatch(filteredTest -> filteredTest.getName() - .equalsIgnoreCase(testClass.getClass().getSimpleName())) || test.getXmlPackages().isEmpty()) { - testClass.deviceConfig = getDeviceConfig(activeDevice); + if (testMethodsToInclude.stream().anyMatch( + filteredTest -> filteredTest.getName().equalsIgnoreCase(testClass.getClass().getSimpleName())) + || test.getXmlPackages().isEmpty() + || test.getSuite().getListeners().stream().noneMatch( + listener -> listener.contains(TestRailFilterListener.class.getSimpleName())) + ) { + testClass.deviceConfig = DeviceConfig.builder() + .deviceName(activeDevice.getModel()) + .udid(activeDevice.getUDID()) + .hsUdid(activeDevice.getHsUDID()) + .deviceAddress(activeDevice.getDeviceAddress()) + .ip(activeDevice.getIp()) + .wdaPort(activeDevice.getWdaPort()) + .port(String.valueOf(SocketUtils.findAvailableTcpPort())) + .useRemoteHeadSpinServer(activeDevice.isUseRemoteHeadSpinServer()) + .hsServerUrl(activeDevice.getHsServerUrl()) + .platformVersion(activeDevice.getPlatformVersion()) + .build(); tests.add(testClass); Logger.get().info(String.format("Adding test : %s to run", testClass.getClass().getSimpleName())); } @@ -410,39 +415,4 @@ private static void reinstallAppForHsAvailableDevices() { ApiSteps.get().installAppOnHeadSpin(appId, udid); } } - - private static DeviceConfig getDeviceConfig(Device device) { - return DeviceConfig.builder() - .deviceName(device.getModel()) - .udid(device.getUDID()) - .hsUdid(device.getHsUDID()) - .deviceAddress(device.getDeviceAddress()) - .ip(device.getIp()) - .wdaPort(device.getWdaPort()) - .port(String.valueOf(SocketUtils.findAvailableTcpPort())) - .useRemoteHeadSpinServer(device.isUseRemoteHeadSpinServer()) - .hsServerUrl(device.getHsServerUrl()) - .platformVersion(device.getPlatformVersion()) - .build(); - } - - private void changeUnavailableDevice(ITestResult testResult) { - Collections.shuffle(deviceConfigList); - Throwable throwable = testResult.getThrowable(); - if (DeviceErrorUtils.isDeviceErrorMessagePresent(throwable, deviceConfig)) { - Logger.get().info(String.format("Adding device %s to the list of devices with issues", deviceConfig.getUdid())); - devicesWithIssuesList.add(deviceConfig); - changeDeviceConfig(); - Logger.get().info(String.format("Changed device config to %s", deviceConfig.getUdid())); - } - } - - private void changeDeviceConfig() { - Logger.get().info("Changing device configuration"); - deviceConfig = deviceConfigList.stream() - .filter(device -> !deviceConfig.getUdid().equals(device.getUdid())) - .filter(device -> devicesWithIssuesList.stream().noneMatch(issueDevice -> issueDevice.getUdid().equals(device.getUdid()))) - .findFirst() - .orElseThrow(() -> new PMException("No new device found.")); - } } diff --git a/AI/mfc/automation/base/ICollectablesTest.java b/AI/mfc/automation/base/ICollectablesTest.java index 37cdd5b..9d30438 100644 --- a/AI/mfc/automation/base/ICollectablesTest.java +++ b/AI/mfc/automation/base/ICollectablesTest.java @@ -6,7 +6,6 @@ import com.myproject.automation.steps.ui.LobbySteps; import com.myproject.automation.steps.ui.collectables.*; import com.myproject.automation.steps.ui.randomrewards.OrbRewardsSteps; -import com.myproject.automation.steps.ui.randomrewards.OrbTotalRewardsSteps; import com.myproject.automation.steps.ui.randomrewards.RewardPacksRevealSteps; import java.util.stream.IntStream; @@ -18,59 +17,59 @@ public interface ICollectablesTest { default void upgradeTotalProgressAndClaimUpgradeReward() { TotalProgressScreenSteps.get().assertThatTotalProgressScreenIsPresent(); + AppSteps.get().waitForStableResponseFromWebsocket(); TotalProgressScreenSteps.get().clickUpgrade(); + CollectablesAlbumSteps.get().clickSkipBtnIfPresent(); ClaimUpgradeRewardPopupSteps.get().assertClaimUpgradeRewardPopupIsPresent(); AppSteps.get().waitForStableResponseFromWebsocket(); ClaimUpgradeRewardPopupSteps.get().claimUpgradeReward(); } - default void completeBronzeSetWithoutLastItem(User user) { - IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, BRONZE_FULL_SET_BOX)); - IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), BRONZE_FULL_SET_BOX)); - ApiSteps.get().addBoxForUser(user, BRONZE_SET_BOX_WITHOUT_LAST_ITEM); - ApiSteps.get().openBoxForUser(user.getApiToken(), BRONZE_SET_BOX_WITHOUT_LAST_ITEM); - AppSteps.get().launchApp(); + default void completeBaseSetWithoutLastItem(User user) { + IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, BASE_FULL_SET_BOX)); + IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), BASE_FULL_SET_BOX)); + ApiSteps.get().addBoxForUser(user, BASE_SET_BOX_WITHOUT_LAST_ITEM); + ApiSteps.get().openBoxForUser(user.getApiToken(), BASE_SET_BOX_WITHOUT_LAST_ITEM); + AppSteps.get().relaunchApp(); LobbySteps.get().assertThatLobbyIsOpened(); - LobbySteps.get().tapCollectablesIcon(); + LobbySteps.get().clickCollectablesIcon(); upgradeTotalProgressAndClaimUpgradeReward(); RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent(); RewardPacksRevealSteps.get().clickSkipIfPresent(); - OrbRewardsSteps.get().assertThatOrbRewardsViewIsPresent(); - OrbRewardsSteps.get().clickOpenAll(); - RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent(); - RewardPacksRevealSteps.get().clickSkipIfPresent(); - OrbTotalRewardsSteps.get().assertThatOrbTotalRewardsViewIsPresent(); - OrbTotalRewardsSteps.get().clickFinish(); + openAllOrbRewards(); } - default void upgradeToSilverLevel(User user) { - completeBronzeSetWithoutLastItem(user); - ApiSteps.get().addBoxForUser(user, BOX_BRONZE_ITEM_7); + default void upgradeToSilverLevel(User user, boolean isSetCompletedScreenCanBeClosed) { + completeBaseSetWithoutLastItem(user); + ApiSteps.get().addBoxForUser(user, BOX_BASE_ITEM_7); AppSteps.get().relaunchApp(); LobbySteps.get().assertThatLobbyIsOpened(); - LobbySteps.get().tapCollectablesIcon(); + LobbySteps.get().clickCollectablesIcon(); CollectablesCardsSteps.get().assertThatCollectableCardsScreenIsPresent(); CollectablesCardsSteps.get().skipAll(); upgradeTotalProgressAndClaimUpgradeReward(); SetCompletedSteps.get().assertThatSetCompletedScreenIsPresent(); + SetCompletedSteps.get().assertThatClaimBtnIsPresent(); + if (isSetCompletedScreenCanBeClosed) { + SetCompletedSteps.get().clickClaimBtn(); + SetCompletedSteps.get().assertThatSetCompletedScreenIsNotPresent(); + } } default void setSilverState(User user) { - IntStream.range(0, BOXES_AMOUNT_TO_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, BRONZE_FULL_SET_BOX)); - IntStream.range(0, BOXES_AMOUNT_TO_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), BRONZE_FULL_SET_BOX)); + IntStream.range(0, BOXES_AMOUNT_TO_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, BASE_FULL_SET_BOX)); + IntStream.range(0, BOXES_AMOUNT_TO_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), BASE_FULL_SET_BOX)); AppSteps.get().relaunchApp(); LobbySteps.get().assertThatLobbyIsOpened(); - LobbySteps.get().tapCollectablesIcon(); - TotalProgressScreenSteps.get().assertThatTotalProgressScreenIsPresent(); - TotalProgressScreenSteps.get().clickUpgrade(); - CollectablesAlbumSteps.get().clickSkipBtn(); - ClaimUpgradeRewardPopupSteps.get().assertClaimUpgradeRewardPopupIsPresent(); - ApiSteps.get().openBoxForUser(user.getApiToken(), BOX_BRONZE_ITEM_1); - ApiSteps.get().openBoxForUser(user.getApiToken(), BOX_BRONZE_ITEM_1); - ApiSteps.get().markItemsAsShown(user.getApiToken(), BRONZE_FULL_SET_BOX); - AppSteps.get().relaunchApp(); - LobbySteps.get().assertThatLobbyIsOpened(); - LobbySteps.get().tapCollectablesIcon(); + LobbySteps.get().clickCollectablesIcon(); + upgradeTotalProgressAndClaimUpgradeReward(); + RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent(); + RewardPacksRevealSteps.get().clickSkipIfPresent(); + openAllOrbRewards(); + SetCompletedSteps.get().assertThatSetCompletedScreenIsPresent(); + SetCompletedSteps.get().assertThatClaimBtnIsPresent(); + SetCompletedSteps.get().clickClaimBtn(); + openAllOrbRewards(); CollectablesAlbumSteps.get().assertThatCollectablesAlbumIsPresent(); CollectablesAlbumSteps.get().assertThatRewardSetTextIsSameAsExpected(SILVER_SET_REWARD_MESSAGE); } @@ -78,17 +77,21 @@ default void setSilverState(User user) { default void upgradeToGoldLevel(User user) { IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, SILVER_FULL_SET_BOX)); IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), SILVER_FULL_SET_BOX)); - AppSteps.get().launchApp(); + AppSteps.get().relaunchApp(); LobbySteps.get().assertThatLobbyIsOpened(); - LobbySteps.get().tapCollectablesIcon(); + LobbySteps.get().clickCollectablesIcon(); upgradeTotalProgressAndClaimUpgradeReward(); ApiSteps.get().addBoxForUser(user, SILVER_FULL_SET_BOX); AppSteps.get().relaunchApp(); LobbySteps.get().assertThatLobbyIsOpened(); - LobbySteps.get().tapCollectablesIcon(); + LobbySteps.get().clickCollectablesIcon(); CollectablesCardsSteps.get().assertThatCollectableCardsScreenIsPresent(); CollectablesCardsSteps.get().skipAll(); upgradeTotalProgressAndClaimUpgradeReward(); + RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent(); + RewardPacksRevealSteps.get().clickSkip(); + OrbRewardsSteps.get().assertThatOrbRewardsViewIsPresent(); + OrbRewardsSteps.get().clickFinish(); SetCompletedSteps.get().assertThatSetCompletedScreenIsPresent(); } @@ -96,23 +99,18 @@ default void completeGoldState(User user) { upgradeToSilverAndGoldLevel(user); SetCompletedSteps.get().assertThatClaimBtnIsPresent(); SetCompletedSteps.get().clickClaimBtn(); - RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent(); - OrbRewardsSteps.get().assertThatOrbRewardsViewIsPresent(); - OrbRewardsSteps.get().clickOpenAll(); - RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent(); - OrbTotalRewardsSteps.get().assertThatOrbTotalRewardsViewIsPresent(); - OrbTotalRewardsSteps.get().clickFinish(); + openAllOrbRewards(); CollectablesAlbumSteps.get().assertThatCollectablesAlbumIsPresent(); IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().addBoxForUser(user, GOLD_FULL_SET_BOX)); IntStream.range(0, BOXES_AMOUNT_TO_ALMOST_COMPLETE_SET).forEach(box -> ApiSteps.get().openBoxForUser(user.getApiToken(), GOLD_FULL_SET_BOX)); - AppSteps.get().launchApp(); + AppSteps.get().relaunchApp(); LobbySteps.get().assertThatLobbyIsOpened(); - LobbySteps.get().tapCollectablesIcon(); + LobbySteps.get().clickCollectablesIcon(); upgradeTotalProgressAndClaimUpgradeReward(); ApiSteps.get().addBoxForUser(user, GOLD_FULL_SET_BOX); AppSteps.get().relaunchApp(); LobbySteps.get().assertThatLobbyIsOpened(); - LobbySteps.get().tapCollectablesIcon(); + LobbySteps.get().clickCollectablesIcon(); CollectablesCardsSteps.get().assertThatCollectableCardsScreenIsPresent(); CollectablesCardsSteps.get().skipAll(); upgradeTotalProgressAndClaimUpgradeReward(); @@ -120,7 +118,7 @@ default void completeGoldState(User user) { } default void upgradeToSilverAndGoldLevel(User user) { - upgradeToSilverLevel(user); + upgradeToSilverLevel(user, true); upgradeToGoldLevel(user); } @@ -128,7 +126,7 @@ default void makeTrade(User user, int duplicateBalance) { ApiSteps.get().setUserDuplicateBalanceTo(user, duplicateBalance); AppSteps.get().relaunchApp(); LobbySteps.get().assertThatLobbyIsOpened(); - LobbySteps.get().tapCollectablesIcon(); + LobbySteps.get().clickCollectablesIcon(); CollectablesAlbumSteps.get().assertThatCollectablesAlbumIsPresent(); CollectablesAlbumSteps.get().clickTradeButton(); TradeSteps.get().assertThatTradeScreenIsPresent(); @@ -139,4 +137,14 @@ default void makeTrade(User user, int duplicateBalance) { CollectablesCardsSteps.get().skipAll(); TotalProgressScreenSteps.get().assertThatTotalProgressScreenIsPresent(); } + + default void openAllOrbRewards() { + OrbRewardsSteps.get().assertThatOrbRewardsViewIsPresent(); + OrbRewardsSteps.get().clickOpenAll(); + RewardPacksRevealSteps.get().assertThatRewardsPackRevealScreenIsPresent(); + RewardPacksRevealSteps.get().clickSkipIfPresent(); + OrbRewardsSteps.get().assertThatOrbRewardsViewIsPresent(); + OrbRewardsSteps.get().clickFinish(); + OrbRewardsSteps.get().assertThatOrbRewardsViewIsNotPresent(); + } } diff --git a/AI/mfc/automation/screens/LobbyScreen.java b/AI/mfc/automation/screens/LobbyScreen.java index c6784f1..0b47e5b 100644 --- a/AI/mfc/automation/screens/LobbyScreen.java +++ b/AI/mfc/automation/screens/LobbyScreen.java @@ -38,7 +38,7 @@ public class LobbyScreen extends BaseScreen { private final WsImage imgLockedStarLevel = new WsImage("LockedStarLevelButton", "Locked Star Level Image"); private final WsButton btnLS = new WsButton("LightningStrikesLobbyView>LS_Button Button", "Lightning Strikes Button"); private final WsText txtLSRewardCount = new WsText("RewardReady>RewardsCount TextMeshProUGUI", "LS Reward Count Text"); - private final WsImage imgCollectablesIcon = new WsImage("CollectablesButtonContainer Image", "Collectables icon Image"); + private final WsButton btnCollectablesButton = new WsButton("CollectablesButtonContainer Button", "Collectables Button"); private final WsImage imgLogoBig = new WsImage("LogoBig Image", "Big Logo Container Image"); private final WsText txtCardsQuantity = new WsText("ReadyToCollect>Image>Quantity TextMeshProUGUI", "Collectables cards quantity Text"); private final WsText txtUpgradeNotification = new WsText("Component_Notification_Piglets_Reset(Clone)>Mask>BalancePanel>PiggyNotificationHeader", @@ -172,12 +172,12 @@ public int getLSRewardCounterValue() { return Integer.parseInt(txtLSRewardCount.getText()); } - public void tapCollectablesIcon() { - imgCollectablesIcon.tap(); + public void clickCollectablesButton() { + btnCollectablesButton.click(); } - public boolean isCollectablesIconPresent() { - return imgCollectablesIcon.waitForIsPresent(); + public boolean isCollectablesButtonPresent() { + return btnCollectablesButton.waitForIsPresent(); } public int getCardsQuantity() { diff --git a/AI/mfc/automation/screens/collectables/CollectablesAlbumScreen.java b/AI/mfc/automation/screens/collectables/CollectablesAlbumScreen.java index 5be31a9..6c4fa85 100644 --- a/AI/mfc/automation/screens/collectables/CollectablesAlbumScreen.java +++ b/AI/mfc/automation/screens/collectables/CollectablesAlbumScreen.java @@ -20,7 +20,7 @@ public class CollectablesAlbumScreen extends BaseScreen { private static final String LOC_ITEM_COMMON_PART = "CollectablesSetItem_View(Clone)"; - private static final String LOC_IMG_ITEM = LOC_ITEM_COMMON_PART + ">CapsuleContainer Image"; + private static final String LOC_IMG_ITEM = LOC_ITEM_COMMON_PART + ">!_Required>!_CapsuleImage Image"; private static final String LOC_BTN_ITEM = LOC_ITEM_COMMON_PART + " Button"; private static final WsImage IMG_ITEM = new WsImage(LOC_IMG_ITEM, "Item Image"); private static final String LOC_BTN_ITEM_PROGRESS = "ProgressPanel>Progress_Text"; @@ -28,7 +28,7 @@ public class CollectablesAlbumScreen extends BaseScreen { private static final String LOC_IMG_COMPLETE_TICK = "CompletedTick Image"; private final WsButton btnClose = new WsButton("CloseButton Button", "Close Button"); private final WsButton btnSkip = new WsButton("SkipButton Button", "Skip Button"); - private final WsButton btnTrade = new WsButton("LLab_Button_Trade", "Trade Button"); + private final WsButton btnTrade = new WsButton("CollectablesTrade_Button Button", "Trade Button"); private final WsImage imgCompleteTick = new WsImage(LOC_IMG_COMPLETE_TICK, "Complete checkmark Image"); private final WsText txtLightningReward = new WsText("CollectablesSetReward_Lightning(Clone)>JackpotValue_Text TextMeshProUGUI", "Lightning Reward Text"); private final WsText txtCoinReward = new WsText("CollectablesSetReward_Coins(Clone)>JackpotValue_Text TextMeshProUGUI", "Coin Reward Text"); @@ -42,7 +42,9 @@ public CollectablesAlbumScreen() { } public String getProgressValue(int itemNumber) { - return getProgressText().get(itemNumber - 1).getText(); + List progressValues = getProgressText(); + Collections.reverse(progressValues); + return progressValues.get(itemNumber - 1).getText(); } public boolean isCloseBtnPresent() { @@ -109,7 +111,7 @@ public boolean isOrbRewardPresent() { public boolean isOrbRewardPresent(Orb orbType) { return getListOfOrbRewards().stream() - .anyMatch(y -> y.getAttribute(Attribute.SPRITE).contains(orbType.getOrbName())); + .anyMatch(y -> y.getAttribute(Attribute.SPRITE).contains(orbType.getSprite())); } public boolean isItemInStatePresent(CollectablesItem item, String state) { diff --git a/AI/mfc/automation/screens/collectables/CollectablesCardsScreen.java b/AI/mfc/automation/screens/collectables/CollectablesCardsScreen.java index a0926c8..7c93761 100644 --- a/AI/mfc/automation/screens/collectables/CollectablesCardsScreen.java +++ b/AI/mfc/automation/screens/collectables/CollectablesCardsScreen.java @@ -1,6 +1,7 @@ package com.myproject.automation.screens.collectables; import com.myproject.automation.base.BaseScreen; +import com.myproject.automation.base.DataHolder; import com.myproject.automation.constants.CommonTestConstants; import com.myproject.automation.constants.RegexExpressions; import com.myproject.automation.drivers.websocket.SocketDriver; @@ -12,23 +13,27 @@ import com.myproject.automation.enums.collectables.CardsFrontImageState; import com.myproject.automation.enums.collectables.CollectablesItem; import com.myproject.automation.enums.collectables.ItemsStateOnTopCardsScreen; +import com.myproject.automation.enums.config.Timeout; import com.myproject.automation.models.pojo.Element; import com.myproject.automation.utils.ParseUtil; import com.myproject.automation.utils.RegexUtils; +import com.myproject.automation.utils.waiters.SmartWait; import org.apache.commons.lang3.StringUtils; import java.util.Collections; import java.util.List; +import java.util.function.Supplier; import java.util.stream.Collectors; +import java.util.stream.Stream; public class CollectablesCardsScreen extends BaseScreen { - private static final String LOC_CARD_BTN = "CollectiblesCardItem_Container>Button"; - private static final String LOC_POINTS = "CardPoints_Text"; - private static final String LOC_COLLECTED_POINTS = "Points_Text_"; + private static final String LOC_CARD_BTN = "CollectablesSetItem_View_Reveal(Clone) Button"; + private static final String LOC_POINTS = "Footer_Container>ProgressPanel>Progress_Text"; + private static final String LOC_COLLECTED_POINTS = "TradePoints_UpgradeText"; private static final String LOC_CARDS_FRONT_IMG = "Front Image"; private static final String LOC_ITEM_ON_TOP_OF_SCREEN_IMG = "CollectablesCardTopBar(Clone)>Container>AssetContainer"; - private static final WsText TXT_TRADE = new WsText("CollectablesCardsRevealView(Clone)>Body>RevealsFlow>TradeButton>TradeText TextMeshProUGUI", + private static final WsText TXT_TRADE = new WsText("CollectablesCardsRevealView(Clone)>Body>RevealsFlow>TradeContainer>TradeText TextMeshProUGUI", "Trade Text"); private final WsButton btnSkipAll = new WsButton("RevealAllButton Button", "Skip all Button"); private final WsButton btnNext = new WsButton("NextButton Button", "Next Button"); @@ -36,7 +41,7 @@ public class CollectablesCardsScreen extends BaseScreen { private final WsButton btnContinue = new WsButton("ContinueButton Button", "Continue Button"); private final WsText txtCardsCounter = new WsText("CardsCount", "Cards counter Text"); private final WsImage imgItemAsset = new WsImage("AssetContainer", "Item asset Image"); - private final WsText txtTopBarCollectablesPoints = new WsText("SummaryValueContainer>Points_Text", + private final WsText txtTopBarCollectablesPoints = new WsText("TradePoints_RegularText TextMeshProUGUI", "Top bar Collectables Card points Text"); private final WsText txtBottomBarTradePoints = new WsText("TradePointsContainer>TradePointsCount_Text", "Bottom bar trade points Text"); @@ -185,12 +190,12 @@ public boolean areTradePointsNotPresent(int tradePoints) { } private List getListOfCardPoints() { - List listOfCardPoints = SocketDriver.getElements(LOC_POINTS, WebsocketComponentType.TMPRO_TEXT).stream() + Supplier> cardPointText = () -> SocketDriver.getElements(LOC_POINTS, WebsocketComponentType.TMPRO_TEXT) + .stream() .filter(element -> element != null && StringUtils.isNotEmpty(element.getText())) - .map(el -> new WsText(el.getName(), el.getName())) - .collect(Collectors.toList()); - Collections.reverse(listOfCardPoints); - return listOfCardPoints; + .map(el -> new WsText(el.getName(), el.getName())); + SmartWait.waitForTrue(i -> cardPointText.get().findAny().isPresent()); + return cardPointText.get().collect(Collectors.toList()); } private List getListCardsBtn() { @@ -207,23 +212,21 @@ private List getListOfUnopenedCardsBtn() { } private List getCards() { + SmartWait.waitForTrue(i -> !SocketDriver.getElements(LOC_CARD_BTN, WebsocketComponentType.UNITY_BUTTON).isEmpty(), + DataHolder.getTimeout(Timeout.SHORT_ELEMENT_APPEARANCE_SECONDS)); return SocketDriver.getElements(LOC_CARD_BTN, WebsocketComponentType.UNITY_BUTTON); } private List getListOfTopbarAssets() { - List listOfTopbarAssets = SocketDriver.getElements(LOC_COLLECTED_POINTS, WebsocketComponentType.TMPRO_TEXT).stream() + return SocketDriver.getElements(LOC_COLLECTED_POINTS, WebsocketComponentType.TMPRO_TEXT).stream() .filter(element -> element != null && StringUtils.isNotEmpty(element.getText())) .map(el -> new WsText(el.getName(), el.getName())) .collect(Collectors.toList()); - Collections.reverse(listOfTopbarAssets); - return listOfTopbarAssets; } private List getListOfCardsFrontImages() { - List listOfCardsFrontImages = SocketDriver.getElements(LOC_CARDS_FRONT_IMG, WebsocketComponentType.UNITY_IMAGE).stream() + return SocketDriver.getElements(LOC_CARDS_FRONT_IMG, WebsocketComponentType.UNITY_IMAGE).stream() .map(el -> new WsImage(el.getName(), el.getName())) .collect(Collectors.toList()); - Collections.reverse(listOfCardsFrontImages); - return listOfCardsFrontImages; } } diff --git a/AI/mfc/automation/screens/collectables/ItemsDetailsScreen.java b/AI/mfc/automation/screens/collectables/ItemsDetailsScreen.java index c7dc003..6a132de 100644 --- a/AI/mfc/automation/screens/collectables/ItemsDetailsScreen.java +++ b/AI/mfc/automation/screens/collectables/ItemsDetailsScreen.java @@ -17,7 +17,7 @@ public class ItemsDetailsScreen extends BaseScreen { private final WsImage imgOrb = new WsImage("RewardPack(Clone)>IconImage Image", "Orb Image"); private final WsImage imgCoins = new WsImage("CoinsImage Image", "Coins Image"); private final WsImage imgLightning = new WsImage("LightningImage Image", "Lightning Image"); - private final WsButton btnBack = new WsButton("CollectablesBack_Button Button", "Back Button"); + private final WsButton btnBack = new WsButton("CollectablesBack_Button Button", "Back Button"); public ItemsDetailsScreen() { super(TXT_HEADER, "Items details screen", true); diff --git a/AI/mfc/automation/screens/collectables/SetCompletedScreen.java b/AI/mfc/automation/screens/collectables/SetCompletedScreen.java index 1ea1c97..685fb0f 100644 --- a/AI/mfc/automation/screens/collectables/SetCompletedScreen.java +++ b/AI/mfc/automation/screens/collectables/SetCompletedScreen.java @@ -21,18 +21,18 @@ import java.util.List; import java.util.stream.Collectors; -import static com.myproject.automation.enums.collectables.ItemsState.BRONZE; +import static com.myproject.automation.enums.collectables.ItemsState.BASE; import static com.myproject.automation.enums.collectables.ItemsState.SILVER; public class SetCompletedScreen extends BaseScreen { private static final String LOC_IMG_ITEM = ">CapsuleContainer Image"; - private static final String LOC_REWARD_PACK = "RewardPack(Clone)>AmountText TextMeshProUGUI"; - private static final String LOC_REWARD_PACK_IMG = "RewardPack(Clone)>IconImage Image"; + private static final String LOC_REWARD_PACK = "CollectablesSetReward_RewardPackSetComplete(Clone)>AmountText TextMeshProUGUI"; + private static final String LOC_REWARD_PACK_IMG = "CollectablesSetReward_RewardPackSetComplete(Clone)>IconImage Image"; private static final WsText TXT_SET_COMPLETED_TEXT = new WsText("SetCompletedText TextMeshProUGUI", "Set completed Text"); private final WsButton btnClaim = new WsButton("ClaimButtonContainer>ClaimButton Button", "Claim Button"); - private final WsText txtCoinReward = new WsText("Coins(Clone)>JackpotValue_Text TextMeshProUGUI", "Coins Text"); - private final WsText txtLightningReward = new WsText("Lightning(Clone)>JackpotValue_Text TextMeshProUGUI", "Lightning Text"); + private final WsText txtCoinReward = new WsText("CollectablesSetReward_CoinsSetComplete(Clone)>JackpotValue_Text TextMeshProUGUI", "Coins Text"); + private final WsText txtLightningReward = new WsText("LightningSetComplete(Clone)>JackpotValue_Text TextMeshProUGUI", "Lightning Text"); private final WsImage imgLightning = new WsImage("Spinner>Lightning Image", "Lightning Animation Image"); public SetCompletedScreen() { @@ -40,7 +40,7 @@ public SetCompletedScreen() { } public boolean isBronzeTurnedToSilver() { - AwaitilityWrapper.waitForCondition(() -> getNumberOfContainers(BRONZE) == CollectablesSet.BRONZE.getItemsCount(), + AwaitilityWrapper.waitForCondition(() -> getNumberOfContainers(BASE) == CollectablesSet.BASE.getItemsCount(), DataHolder.getTimeout(Timeout.DEFAULT_ELEMENT_GET_SECONDS)); return AwaitilityWrapper.waitForCondition(() -> getNumberOfContainers(SILVER) == CollectablesSet.SILVER.getItemsCount(), DataHolder.getTimeout(Timeout.DEFAULT_ELEMENT_GET_SECONDS)); @@ -89,10 +89,10 @@ public int getRewardPackCount() { public boolean isLightningAnimationPresent() { return imgLightning.waitForIsPresent(); } - + public boolean isOrbRewardPresent(Orb orbType) { return getListOfOrbRewards().stream() - .anyMatch(y -> y.getAttribute(Attribute.SPRITE).contains(orbType.getOrbName())); + .anyMatch(y -> y.getAttribute(Attribute.SPRITE).contains(orbType.getSprite())); } public boolean isCoinRewardPresent() { diff --git a/AI/mfc/automation/screens/collectables/TotalProgressScreen.java b/AI/mfc/automation/screens/collectables/TotalProgressScreen.java index b2a5e5b..87c5809 100644 --- a/AI/mfc/automation/screens/collectables/TotalProgressScreen.java +++ b/AI/mfc/automation/screens/collectables/TotalProgressScreen.java @@ -20,11 +20,11 @@ public class TotalProgressScreen extends BaseScreen { "Total progress header Text"); private final WsButton btnContinueClaim = new WsButton("ClaimButton Button", "Continue Claim Button"); private final WsButton btnContinueClose = new WsButton("CloseButton Button", "Continue Close Button"); - private final WsText txtCollectedTotalPoints = new WsText("TradePoints_Text", + private final WsText txtCollectedTotalPoints = new WsText("TradePoints_RegularText TextMeshProUGUI", "Collected Total points Text"); private final WsText txtTradePoints = new WsText("TradePointsContainer>TradePointsCount_Text", "Trade points Text"); - private final WsImage imgJackpotCard = new WsImage("CollectablesJackpotCardSummary(Clone)>Container>AssetContainer Image", + private final WsImage imgJackpotCard = new WsImage("CollectablesJackpotCardSummary(Clone)>Container>AssetContainer Image", "Jackpot Card Image"); public TotalProgressScreen() { diff --git a/AI/mfc/automation/screens/collectables/TradeScreen.java b/AI/mfc/automation/screens/collectables/TradeScreen.java index f8992ab..aab67c3 100644 --- a/AI/mfc/automation/screens/collectables/TradeScreen.java +++ b/AI/mfc/automation/screens/collectables/TradeScreen.java @@ -25,10 +25,10 @@ public class TradeScreen extends BaseScreen { private static final String LOC_TRADE_PACK_IMG = "TradePackItem Image"; private static final String LOC_UNAVAILABLE_TRADE_PRICES_TXT = "TradeButton_Default>TradePointsCount_Text TextMeshProUGUI"; private static final String LOC_AVAILABLE_TRADE_PRICE_TXT = "TradeButtonText_Text TextMeshProUGUI"; - private static final WsText TXT_HEADER = new WsText("CollectablesTradeView(Clone)>Header>Header_Text", "Header Text"); - private final WsButton btnClose = new WsButton("CollectablesTradeView(Clone)>Header>CloseButton", "Close Button"); + private static final WsText TXT_HEADER = new WsText("CollectablesTradeView(Clone)>Background>BGCanvas0>Header>Header_Text", "Header Text"); + private final WsButton btnClose = new WsButton("CollectablesTradeView(Clone)>Background>BGCanvas0>Header>ButtonsBar>CloseButton", "Close Button"); private final WsButton btnTradePrice = new WsButton("TradeButton_Enabled Button", "Trade Price Button"); - private final WsButton btnInfo = new WsButton("InfoButton>InfoIcon Button", "Info Button"); + private final WsButton btnInfo = new WsButton("InfoButton Button", "Info Button"); private final WsImage imgDisabledTradePrice = new WsImage("TradeButton_Disabled>Bg_Image Image", "Disabled trade Image"); private final WsImage imgProgressBar = new WsImage("ProgressBarContainer>ProgressBar", "Progress Bar Image"); private final WsImage imgHighlight = new WsImage("TradePackTileContainer_0>TradePackTile>Milestone", "Highlight Image"); diff --git a/AI/mfc/automation/screens/views/OrbRewardsView.java b/AI/mfc/automation/screens/views/OrbRewardsView.java index 5f1b0f6..3472586 100644 --- a/AI/mfc/automation/screens/views/OrbRewardsView.java +++ b/AI/mfc/automation/screens/views/OrbRewardsView.java @@ -7,6 +7,7 @@ import com.myproject.automation.elements.ws.WsImage; import com.myproject.automation.elements.ws.WsText; import com.myproject.automation.enums.Attribute; +import com.myproject.automation.enums.OrbReward; import com.myproject.automation.enums.WebsocketComponentType; import com.myproject.automation.utils.ParseUtil; @@ -17,6 +18,7 @@ public class OrbRewardsView extends BaseScreen { protected static final String LOC_IMG_REWARD = "Reward>Icon_Container>Icon_Image"; + protected static final String LOC_TEXT_IMG_REWARD = "%s>RewardContainer Image 0"; private static final String LOC_TOTAL_REWARD_ICON = "TopBar_TotalRewards_Container>CollectableBox>Icon Image"; private static final WsText TXT_YOUR_REWARD = new WsText("NewReward_Text TextMeshProUGUI", "Your reward Text"); private static final WsText AMOUNT_OF_COINS_FROM_REWARD = new WsText("Reward_01>Reward>Icon_Container>Icon_Image>Value_Text TextMeshProUGUI", "Amount of coins Text"); @@ -64,8 +66,9 @@ public void tapAroundFinishBtn() { btnFinish.tapAroundElement(CommonTestConstants.COUNT_OF_TOUCHES_AROUND_ELEMENT); } - public int getRewardValue(String type) { - return ParseUtil.getIntValueWithComma(getReward(type, LOC_IMG_REWARD).getText()); + public int getRewardValue(OrbReward orbReward) { + return ParseUtil.getIntValueWithComma(SocketDriver.getElements( + String.format(LOC_TEXT_IMG_REWARD, orbReward.getRewardNumber())).get(0).getText()); } public int getTotalRewardValue(String type) { diff --git a/AI/mfc/automation/screens/views/collectables/CollectablesMainTutorialView.java b/AI/mfc/automation/screens/views/collectables/CollectablesMainTutorialView.java index c6c28be..0f8d3c8 100644 --- a/AI/mfc/automation/screens/views/collectables/CollectablesMainTutorialView.java +++ b/AI/mfc/automation/screens/views/collectables/CollectablesMainTutorialView.java @@ -6,7 +6,7 @@ public class CollectablesMainTutorialView extends BaseScreen { - private static final String LOC_FIRST_TUTORIAL_CARD = "Page0%s>Container>TutorialCard01>HeaderText TextMeshProUGUI"; + private static final String LOC_FIRST_TUTORIAL_CARD = "Page0%s>Container>TutorialCard01>Avatar_Frame_Left>Text_Headline TextMeshProUGUI"; private static final WsButton BTN_CLOSE = new WsButton("FTUE_CollectablesMainPopUp(Clone)>CloseButton Button", "Close Button"); private final WsButton btnNextArrow = new WsButton("ButtonArrowNext Button", "Next Arrow Button"); private final WsButton btnPreviousArrow = new WsButton("ButtonArrowPrevious Button", "Previous Arrow Button"); diff --git a/AI/mfc/automation/screens/views/collectables/CollectablesTradingTutorialView.java b/AI/mfc/automation/screens/views/collectables/CollectablesTradingTutorialView.java index 5a95ed7..7ff8833 100644 --- a/AI/mfc/automation/screens/views/collectables/CollectablesTradingTutorialView.java +++ b/AI/mfc/automation/screens/views/collectables/CollectablesTradingTutorialView.java @@ -5,7 +5,7 @@ public class CollectablesTradingTutorialView extends BaseScreen { - private static final WsButton BTN_CLOSE = new WsButton("FTUE_CollectablesTradingPopUp(Clone)>CloseButton Button ", "Close Button"); + private static final WsButton BTN_CLOSE = new WsButton("FTUE_CollectablesTradingPopUp(Clone)>CloseButton Button", "Close Button"); public CollectablesTradingTutorialView() { super(BTN_CLOSE, "Collactables Trading Tutorial view"); diff --git a/AI/mfc/automation/steps/ui/LobbySteps.java b/AI/mfc/automation/steps/ui/LobbySteps.java index 04b26d6..4d1d9f7 100644 --- a/AI/mfc/automation/steps/ui/LobbySteps.java +++ b/AI/mfc/automation/steps/ui/LobbySteps.java @@ -68,8 +68,8 @@ public void openLightningStrikes() { } @Step("Tapping Collectables icon") - public void tapCollectablesIcon() { - new LobbyScreen().tapCollectablesIcon(); + public void clickCollectablesIcon() { + new LobbyScreen().clickCollectablesButton(); } @Step("Tapping any available slot") @@ -242,7 +242,7 @@ public void assertThatCardsQuantityOnCollectablesButtonEqualsTo(int cardsAmount) @Step("Asserting that Collectables icon is present in Lobby'") public void assertThatCollectablesIconIsPresent() { - assertion.assertTrue(new LobbyScreen().isCollectablesIconPresent(), "Collectables icon is not present in Lobby"); + assertion.assertTrue(new LobbyScreen().isCollectablesButtonPresent(), "Collectables icon is not present in Lobby"); } @Step("Asserting that Upgrade notification is present") diff --git a/AI/mfc/automation/steps/ui/collectables/CollectablesAlbumSteps.java b/AI/mfc/automation/steps/ui/collectables/CollectablesAlbumSteps.java index f8d7a5a..5b877a8 100644 --- a/AI/mfc/automation/steps/ui/collectables/CollectablesAlbumSteps.java +++ b/AI/mfc/automation/steps/ui/collectables/CollectablesAlbumSteps.java @@ -13,16 +13,20 @@ import com.myproject.automation.screens.collectables.CollectablesLoadingScreen; import com.myproject.automation.screens.collectables.ItemsDetailsScreen; import com.myproject.automation.steps.api.ApiSteps; +import com.myproject.automation.steps.ui.AppSteps; import com.myproject.automation.utils.waiters.AwaitilityWrapper; +import com.myproject.automation.utils.waiters.SmartWait; import io.qameta.allure.Step; -import org.apache.commons.lang3.StringUtils; import org.openqa.selenium.Point; import org.testng.asserts.SoftAssert; import java.util.List; +import java.util.function.Supplier; import java.util.stream.IntStream; import java.util.stream.Stream; +import static com.myproject.automation.constants.CollectablesConstants.COUNT_ITEMS_ON_SET; + public class CollectablesAlbumSteps extends BaseSteps { private static ThreadLocal stepsInstanceHolder = new InheritableThreadLocal<>(); @@ -112,8 +116,8 @@ public void assertThatLoadingScreenIsPresent() { @Step("Asserting that Lobby decor item {itemNumber} progress value is correct on 'Collectables Album'") public void assertThatLobbyDecorItemProgressIsCorrect(int itemNumber, String progressValue) { - assertion.assertTrue(AwaitilityWrapper.waitForCondition(() -> new CollectablesAlbumScreen().getProgressValue(itemNumber).equals(progressValue), - DataHolder.getTimeout(Timeout.SHORT_CONDITION_SECONDS)), + assertion.assertTrue(AwaitilityWrapper.waitForCondition(() -> new CollectablesAlbumScreen().getProgressValue(itemNumber) + .equals(progressValue), DataHolder.getTimeout(Timeout.SHORT_CONDITION_SECONDS)), "Lobby decor item progress value is not correct"); } @@ -123,11 +127,6 @@ public void assertThatCloseBtnOnCollectablesAlbumIsPresent() { "Close button is not present on the 'Collectables Album' screen"); } - @Step("Asserting that Item name is not the same as expected on the Item details screen") - public void assertItemsNameIsNotSameOnItemDetailsScreen(String itemName) { - assertion.assertNotEquals(new ItemsDetailsScreen().getItemName(), itemName, "Item name is the same as expected on the Item details screen"); - } - @Step("Asserting that Item name is the same as expected on the Item details screen") public void assertItemsNameIsSameOnItemDetailsScreen(String itemName) { assertion.assertEquals(new ItemsDetailsScreen().getItemName(), itemName, "Item name is not the same as expected on the Item details screen"); @@ -164,21 +163,6 @@ public void assertThatLobbyDecorItemsAreDisplayedInSilverState() { softAssert.assertAll(); } - @Step("Asserting that lobby decor items of base state are displayed on the Collectables Home Page") - public void assertThatLobbyDecorItemsAreDisplayedInBaseState() { - SoftAssert softAssert = new SoftAssert(); - Stream.of(CollectablesItem.values()).forEach(x -> { - if (StringUtils.isEmpty(x.getBaseSprite())) { - softAssert.assertTrue(new CollectablesAlbumScreen().isItemNotPresent(x), - String.format("Lobby decor item %s is not displayed in base state on the Collectables Home Page", x)); - } else { - softAssert.assertTrue(new CollectablesAlbumScreen().isItemInStatePresent(x, x.getBaseSprite()), - String.format("Lobby decor item %s is not displayed in base state on the Collectables Home Page", x)); - } - }); - softAssert.assertAll(); - } - @Step("Asserting that complete checkmark is not present") public void assertThatCompleteTickIsNotPresent() { assertion.assertTrue(new CollectablesAlbumScreen().isCompleteTickNotPresent(), "Complete checkmark is present"); @@ -243,4 +227,33 @@ public void assertThatInfoBtnOnCollectablesAlbumIsPresent() { assertion.assertTrue(new CollectablesAlbumScreen().isInfoBtnPresent(), "Info button is not present on the 'Collectables Album' screen"); } + + @Step("Asserting that next item arrows are working correctly") + public void assertThatNextItemArrowsAreWorkingCorrectly() { + assertNavigationArrows(() -> { + goToNextItemOnItemDetailsScreen(); + return null; + }); + } + + @Step("Asserting that previous item arrows are working correctly") + public void assertThatPreviousItemArrowsAreWorkingCorrectly() { + assertNavigationArrows(() -> { + goToPreviousItemOnItemDetailsScreen(); + return null; + }); + } + + private void assertNavigationArrows(Supplier navigationSupplier) { + SoftAssert softAssert = new SoftAssert(); + for (int counter = 0; counter < COUNT_ITEMS_ON_SET; counter++) { + String itemName = getItemNameOnItemDetailsScreen(); + navigationSupplier.get(); + SmartWait.waitForTrue(i -> !new ItemsDetailsScreen().getItemName().equals(itemName), + DataHolder.getTimeout(Timeout.SHORT_CONDITION_SECONDS)); + softAssert.assertNotEquals(new ItemsDetailsScreen().getItemName(), itemName, + "Item name is the same as expected on the Item details screen"); + } + softAssert.assertAll("One or more navigation arrows are not working correctly"); + } } diff --git a/AI/mfc/automation/steps/ui/collectables/CollectablesCardsSteps.java b/AI/mfc/automation/steps/ui/collectables/CollectablesCardsSteps.java index c0eff06..cd4358e 100644 --- a/AI/mfc/automation/steps/ui/collectables/CollectablesCardsSteps.java +++ b/AI/mfc/automation/steps/ui/collectables/CollectablesCardsSteps.java @@ -10,6 +10,7 @@ import com.myproject.automation.screens.collectables.CollectablesCardsScreen; import com.myproject.automation.steps.ui.AppSteps; import com.myproject.automation.utils.waiters.AwaitilityWrapper; +import com.myproject.automation.utils.waiters.SmartWait; import io.qameta.allure.Step; public class CollectablesCardsSteps extends BaseSteps { @@ -24,6 +25,7 @@ public static synchronized CollectablesCardsSteps get() { @Step("Opening card {cardNumber}") public void openCard(int cardNumber) { + AppSteps.get().waitForStableResponseFromWebsocket(); new CollectablesCardsScreen().openCard(cardNumber); } @@ -194,8 +196,9 @@ public void assertThatTotalPointsAmountIsEqualTo(double totalPointsAmount) { @Step("Asserting that bottom bar trade points amount is equal to {totalPointsAmount}") public void assertThatBottomBarTradePointsAmountIsEqualTo(double totalPointsAmount) { - assertion.assertTrue(AwaitilityWrapper.waitForCondition(() -> new CollectablesCardsScreen().getBottomBarTradePointsAmount() == totalPointsAmount, - DataHolder.getTimeout(Timeout.SHORT_CONDITION_SECONDS)), "Bottom bar trade points amount is not equal to expected"); + SmartWait.waitForTrue(i -> new CollectablesCardsScreen().getBottomBarTradePointsAmount() == totalPointsAmount); + assertion.assertEquals(new CollectablesCardsScreen().getBottomBarTradePointsAmount(), totalPointsAmount, + "Bottom bar trade points amount is not equal to expected"); } @Step("Asserting that Collected Total points amount is equal to {totalPointsAmount} on Collectables cards screen") diff --git a/AI/mfc/automation/steps/ui/collectables/TotalProgressScreenSteps.java b/AI/mfc/automation/steps/ui/collectables/TotalProgressScreenSteps.java index 85809b7..ef2ec3d 100644 --- a/AI/mfc/automation/steps/ui/collectables/TotalProgressScreenSteps.java +++ b/AI/mfc/automation/steps/ui/collectables/TotalProgressScreenSteps.java @@ -3,9 +3,14 @@ import com.myproject.automation.base.BaseSteps; import com.myproject.automation.base.DataHolder; import com.myproject.automation.constants.CommonTestConstants; +import com.myproject.automation.drivers.websocket.SocketDriver; import com.myproject.automation.enums.config.Timeout; +import com.myproject.automation.screens.GameScreen; +import com.myproject.automation.screens.LobbyScreen; import com.myproject.automation.screens.collectables.TotalProgressScreen; +import com.myproject.automation.steps.ui.AppSteps; import com.myproject.automation.utils.waiters.AwaitilityWrapper; +import com.myproject.automation.utils.waiters.SmartWait; import io.qameta.allure.Step; public class TotalProgressScreenSteps extends BaseSteps { diff --git a/AI/mfc/automation/steps/ui/randomrewards/OrbRewardsSteps.java b/AI/mfc/automation/steps/ui/randomrewards/OrbRewardsSteps.java index 5ed7082..9942703 100644 --- a/AI/mfc/automation/steps/ui/randomrewards/OrbRewardsSteps.java +++ b/AI/mfc/automation/steps/ui/randomrewards/OrbRewardsSteps.java @@ -61,7 +61,7 @@ public void openAllOrbRewardsIfFinishIsNotPresent() { @Step("Getting reward value from Orb rewards by sprite {sprite}") public double getRewardValueFromOrbRewards(OrbReward orbReward) { - return new OrbRewardsView().getRewardValue(orbReward.getSprite()); + return new OrbRewardsView().getRewardValue(orbReward); } //assertion steps @@ -91,7 +91,7 @@ public void assertThatCardsAmountValueIsPresentOrbRewardsView() { @Step("Asserting that cards amount value on Orb Reward Screen is equal to '{expAmount}'") public void assertThatCardsAmountValueOnOrbRewardScreenIsEqualTo(int expAmount) { AppSteps.get().waitForStableResponseFromWebsocket(); - assertion.assertEquals(new OrbRewardsView().getRewardValue(OrbReward.COLLECTABLES_CARD.getSprite()), expAmount, + assertion.assertEquals(new OrbRewardsView().getRewardValue(OrbReward.COLLECTABLES_CARD), expAmount, String.format("Cards amount value is not equal to expected '%d' on Orb Reward Screen", expAmount)); } diff --git a/AI/mfc/automation/steps/ui/randomrewards/OrbTotalRewardsSteps.java b/AI/mfc/automation/steps/ui/randomrewards/OrbTotalRewardsSteps.java index fd15a60..c282aa4 100644 --- a/AI/mfc/automation/steps/ui/randomrewards/OrbTotalRewardsSteps.java +++ b/AI/mfc/automation/steps/ui/randomrewards/OrbTotalRewardsSteps.java @@ -31,17 +31,17 @@ public void tapAroundFinishBtn() { @Step("Getting coins reward") public double getCoinsReward() { SocketDriver.waitForResponseIsStable(); - return new OrbTotalRewardsView().getRewardValue(OrbReward.COINS.getSprite()); + return new OrbTotalRewardsView().getRewardValue(OrbReward.COINS); } @Step("Getting Lightning reward value") public int getLightningReward() { - return new OrbTotalRewardsView().getRewardValue(OrbReward.LIGHTNING_ICON.getSprite()); + return new OrbTotalRewardsView().getRewardValue(OrbReward.LIGHTNING_ICON); } @Step("Getting Stellar points reward value") public int getStellarPointsReward() { - return new OrbTotalRewardsView().getRewardValue(OrbReward.STELLAR_POINTS_ICON.getSprite()); + return new OrbTotalRewardsView().getRewardValue(OrbReward.STELLAR_POINTS_ICON); } //assertion steps @@ -98,7 +98,7 @@ public void assertThatCollectablesBoxesCountOnNotificationIsCorrectOnCollectOrbR @Step("Asserting that cards amount on Orb Total reward view value is equal to '{expAmount}'") public void assertThatCardsAmountValueOnOrbTotalRewardsViewIsEqualTo(int expAmount) { AppSteps.get().waitForStableResponseFromWebsocket(); - assertion.assertEquals(new OrbTotalRewardsView().getRewardValue(OrbReward.COLLECTABLES_CARD.getSprite()), expAmount, + assertion.assertEquals(new OrbTotalRewardsView().getRewardValue(OrbReward.COLLECTABLES_CARD), expAmount, String.format("Cards amount value is not equal to expected '%d'", expAmount)); }