def test_top_picks_editors_choice_blocks(self, driver):
        # Top picks block swipe
        assert Actions.getTextID(
            self, driver, MainLocators.TOP_PICKS_TITLE_ID) == 'Top Picks'
        assert Actions.getFewTextsXP(
            self, driver, MainLocators.OVERALL_TABS_XP) == ['Games', 'Apps']
        # assert Actions.getAttributeValueXP(self, driver, MainLocators.FIRST_TAB_XP, 'selected') == 'true'
        # assert Actions.getAttributeValueXP(self, driver, MainLocators.SECOND_TAB_XP, 'selected') == 'false'
        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.APP_ICON_ID) == 7
        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.SUBTITLE_APP_ID) == 7

        Actions.swipeSectionsToLeft(self, driver)

        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.APP_ICON_ID) == 4
        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.SUBTITLE_APP_ID) >= 4

        Actions.swipeSectionsToRight(self, driver)

        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.APP_ICON_ID) == 7
        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.SUBTITLE_APP_ID) == 7

        # Top picks block click
        Actions.clickButtonXP(self, driver, MainLocators.SECOND_TAB_XP)

        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.APP_ICON_ID) == 4
        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.SUBTITLE_APP_ID) >= 4

        Actions.clickButtonXP(self, driver, MainLocators.FIRST_TAB_XP)

        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.APP_ICON_ID) == 7
        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.SUBTITLE_APP_ID) == 7

        # Test open app page from top picks block
        assert Actions.isObjectExistsID(
            self, driver, AppPageLocators.GALLERY_BLOCK_ID) is False

        Actions.clickButtonXP(self, driver,
                              MainLocators.APP_TO_OPEN_TOP_PICKS_XP)

        assert Actions.isObjectExistsID(
            self, driver, AppPageLocators.GALLERY_BLOCK_ID) is True

        Actions.clickButtonID(self, driver, AppPageLocators.BACK_BUTTON_ID)

        assert Actions.isObjectExistsID(
            self, driver, AppPageLocators.GALLERY_BLOCK_ID) is False

        Actions.scrollPageToUp(self, driver)

        # Editor's choice block swipe
        assert Actions.getFewTextsXP(self, driver,
                                     MainLocators.OVERALL_TABS_XP) == [
                                         'Games', 'Apps', 'Games', 'Apps'
                                     ]

        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.APP_ICON_ID) == 13

        Actions.swipeSectionsToLeft(self, driver)

        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.APP_ICON_ID) == 10

        Actions.swipeSectionsToRight(self, driver)

        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.APP_ICON_ID) == 13

        # Editor's choice block click
        Actions.clickButtonXP(self, driver, MainLocators.FOURTH_TAB_XP)

        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.APP_ICON_ID) == 10

        Actions.clickButtonXP(self, driver, MainLocators.THIRD_TAB_XP)

        assert Actions.count_of_elements_id(self, driver,
                                            MainLocators.APP_ICON_ID) == 13

        # Test open app page from editors choice  block
        assert Actions.isObjectExistsID(
            self, driver, AppPageLocators.GALLERY_BLOCK_ID) is False

        Actions.clickButtonXP(self, driver,
                              MainLocators.APP_TO_OPEN_EDITORS_CHOICE_XP)

        assert Actions.isObjectExistsID(
            self, driver, AppPageLocators.GALLERY_BLOCK_ID) is True

        Actions.clickButtonID(self, driver, AppPageLocators.BACK_BUTTON_ID)

        assert Actions.isObjectExistsID(
            self, driver, AppPageLocators.GALLERY_BLOCK_ID) is False
Example #2
0
    def test_search(self, driver):
        Actions.clickButtonID(self, driver, MainLocators.SEARCH_BUTTON_ID)

        # Check first part of word
        Actions.search_field(self,
                             driver).set_value(StaticData.FIRST_PART_OF_WORD)
        time.sleep(2)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is True

        first_autocomplete_result_name = Actions.getTextXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP)
        assert first_autocomplete_result_name == StaticData.RED_PLAYER_NAME

        assert Actions.count_of_elements_id(
            self, driver, SearchLocators.RESULTS_APP_COVER_IMAGE) == 0

        driver.long_press_keycode(66)

        assert Actions.count_of_elements_id(
            self, driver, SearchLocators.RESULTS_APP_COVER_IMAGE) == 3

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is False
        assert Actions.isObjectExistsXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP) is False
        # TODO assert Actions.isObjectExistsID() check more than 1 result

        # Check middle part of word
        Actions.search_field(self,
                             driver).set_value(StaticData.MIDDLE_PART_OF_WORD)
        time.sleep(2)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is True

        first_autocomplete_result_name = Actions.getTextXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP)
        assert first_autocomplete_result_name == StaticData.RED_PLAYER_NAME

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is False
        assert Actions.isObjectExistsXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP) is False
        # TODO check that 1 result

        # Check end part of word
        Actions.search_field(self,
                             driver).set_value(StaticData.END_PART_OF_WORD)
        time.sleep(2)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is True

        first_autocomplete_result_name = Actions.getTextXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP)
        assert first_autocomplete_result_name == StaticData.RED_PLAYER_NAME

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is False
        assert Actions.isObjectExistsXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP) is False
        # TODO check that 1 result

        # Check two symbols - no results
        Actions.search_field(self, driver).set_value(StaticData.TWO_SYMBOLS)

        assert Actions.count_of_elements_id(self, driver,
                                            SearchLocators.APP_NAME_ID) == 0

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)

        # Check more than 3 symbols
        Actions.search_field(self, driver).set_value(StaticData.SIX_SYMBOLS)

        assert Actions.isObjectExistsID(
            self, driver, SearchLocators.RED_PLAYER_ICON_ID) is True

        first_autocomplete_result_name = Actions.getTextXP(
            self, driver, SearchLocators.RED_PLAYER_NAME_XP)
        assert first_autocomplete_result_name == StaticData.RED_PLAYER_NAME
        assert Actions.count_of_elements_id(self, driver,
                                            SearchLocators.APP_NAME_ID) == 1

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)

        # Check not existing app
        Actions.search_field(self,
                             driver).set_value(StaticData.NOT_EXISTING_APP)

        assert Actions.count_of_elements_id(self, driver,
                                            SearchLocators.APP_NAME_ID) == 0

        Actions.clickButtonID(self, driver,
                              SearchLocators.CLEAR_FIELD_BUTTON_ID)