def test_create_SSOA_FB_or_IG_Lotm(self):
        country = self.configAB["Conceptual"]["country"]
        project_name = self.configAB["Conceptual"]["project_name"]
        ds_type = "Advanced Audience Data"

        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects(project_name)
        proj_page = ProjectPage(self.webdriver, self.config)
        proj_page.add_audience_button().click()

        audience_page = AudiencePage(self.webdriver, self.config)
        audience_page.add_dataSource(ds_type)
        audience_page.create_advanced_audience_data_criteria(
            'Affinity Audiences', 'Digital Engagement', 'Social Media',
            'Facebook')
        audience_page.add_dataSource(ds_type)
        audience_page.create_advanced_audience_data_criteria(
            'Affinity Audiences', 'Digital Engagement', 'Social Media',
            'Instagram')

        list = self.webdriver.find_elements_by_xpath(
            "//div[contains(@class,'criteria-oper')]/div[text()='AND']")
        list[1].click()
        self.webdriver.find_element_by_xpath("//div[text()='OR']").click()

        audience_page.audience_name_textbox().clear()
        audience_page.audience_name_textbox().send_keys(country +
                                                        " SSOA - FB,IG - Lotm")
        sleep(5)
        audience_page.save_and_create_button().click()
    def test_create_SSOA_FB_and_IG_Lotm(self):
        country = self.configAB["Conceptual"]["country"]
        project_name = self.configAB["Conceptual"]["project_name"]
        ds_type = "Advanced Audience Data"

        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects(project_name)
        proj_page = ProjectPage(self.webdriver, self.config)
        proj_page.add_audience_button().click()

        audience_page = AudiencePage(self.webdriver, self.config)
        audience_page.add_dataSource(ds_type)
        audience_page.create_advanced_audience_data_criteria(
            'Affinity Audiences', 'Digital Engagement', 'Social Media',
            'Facebook')
        audience_page.add_dataSource(ds_type)
        audience_page.create_advanced_audience_data_criteria(
            'Affinity Audiences', 'Digital Engagement', 'Social Media',
            'Instagram')

        audience_page.audience_name_textbox().clear()
        audience_page.audience_name_textbox().send_keys(
            country + " SSAA - FB & IG - Lotm")
        sleep(5)
        audience_page.save_and_create_button().click()
Example #3
0
    def test_create_MSAA_IG_or(self):
        country = self.configAB["Conceptual"]["country"]
        project_name = self.configAB["Conceptual"]["project_name"]

        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects(project_name)
        proj_page = ProjectPage(self.webdriver, self.config)
        proj_page.add_audience_button().click()

        audience_page = AudiencePage(self.webdriver, self.config)
        audience_page.add_dataSource('Browsing Behavior')
        audience_page.create_browsing_behaviour_domain_names('instagram.com')
        sleep(5)
        audience_page.add_dataSource('Advanced Audience Data')
        audience_page.create_advanced_audience_data_criteria(
            'Affinity Audiences', 'Digital Engagement', 'Social Media',
            'Instagram')
        list = self.webdriver.find_elements_by_xpath(
            "//div[contains(@class,'criteria-oper-groups')]/div[text()='AND']")
        list[1].click()
        self.webdriver.find_element_by_xpath("//div[text()='OR']").click()

        audience_page.audience_name_textbox().clear()
        audience_page.audience_name_textbox().send_keys(
            country + " MSAA - IG - JS or Lotm")
        sleep(5)
        audience_page.save_and_create_button().click()
    def test_ssa(self):
        country = self.configAB["Conceptual"]["country"]
        project_name = self.configAB["Conceptual"]["project_name"]
        ds_type = "Advanced Audience Data"

        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects(project_name)
        proj_page = ProjectPage(self.webdriver, self.config)
        proj_page.add_audience_button().click()

        audience_page = AudiencePage(self.webdriver, self.config)
        audience_page.add_dataSource(ds_type)
        audience_page.create_advanced_audience_data_criteria(
            'In-Market Audiences', 'Automotive & Vehicles', 'Cars', 'TRUE')

        audience_page.audience_name_textbox().clear()
        audience_page.audience_name_textbox().send_keys(
            country + " SSA-Auto In Market-Lotm")
        sleep(5)
        audience_page.save_and_create_button().click()
        ###############################################
        proj_page.add_audience_button().click()

        audience_page = AudiencePage(self.webdriver, self.config)
        audience_page.add_dataSource(ds_type)
        audience_page.create_advanced_audience_data_criteria_multiple_attribute_value(
            'In-Market Audiences',
            'Automotive & Vehicles',
            'Car Classifications',
            value=['Luxury SUV', 'Luxury Sedan'])

        audience_page.audience_name_textbox().clear()
        audience_page.audience_name_textbox().send_keys(
            country + " SSOA-Lux Auto In Market-Lotm")
        sleep(5)
        audience_page.save_and_create_button().click()
        ###############################################
        proj_page.add_audience_button().click()

        audience_page = AudiencePage(self.webdriver, self.config)
        audience_page.add_dataSource(ds_type)
        audience_page.create_advanced_audience_data_criteria_multiple_attribute_value(
            'In-Market Audiences',
            'Automotive & Vehicles',
            'Car Classifications',
            value=['Luxury SUV', 'Luxury Sedan'])
        audience_page.add_dataSource(ds_type)
        audience_page.create_advanced_audience_data_criteria_multiple_attribute_value(
            'Purchase History',
            'Automotive & Vehicles',
            'Car Classifications',
            value=['Luxury SUV', 'Luxury Sedan'])

        audience_page.audience_name_textbox().clear()
        audience_page.audience_name_textbox().send_keys(
            country + " SSAA-Lux Auto InMarket & Own-Lotm")
        sleep(5)
        audience_page.save_and_create_button().click()
    def test_create_audience(self):
        project_name = self.configAB["Lotame_Viz"]["project_name"]
        path = os.path.join('testdata', 'sidebar.json')
        print("location:" + path)

        proj_page = ProjectPage(self.webdriver, self.config)
        audience_page = AudiencePage(self.webdriver, self.config)
        home_page = HomePage(self.webdriver, self.config)

        with open(path) as file:
            data = json.load(file)
        for item in range(len(data)):
            link = data[item]["link"]
            #Project Creation
            new_project_name = project_name + '_' + link
            print(new_project_name)
            proj_page.createProject(new_project_name, link)
            sleep(10)
            #Audience Creation
            proj_page.add_audience_button().click()
            sleep(5)
            audience_page.audience_name_textbox().send_keys('Any Travel')
            audience_page.add_dataSource('Advanced Audience Data')
            source = self.webdriver.find_element_by_xpath(
                "//div[contains(@class,'header-label ng-binding ui-draggable-handle') and contains(text(),'Advanced Audience Data Criteria')]"
            )
            target = self.webdriver.find_element_by_xpath(
                "//div[contains(@class, 'criteria-panel-header') and contains(text(),'Define Your Audience')]"
            )
            mouse = ActionChains(self.webdriver)
            mouse.drag_and_drop(source, target).perform()
            audience_page.create_advanced_audience_data_criteria(
                'Purchase History', 'Travel', 'Travel', 'Any  Air Travel')
            audience_page.add_criteria_plusicon().click()
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Travel', 'Travel', 'Any Travel')
            sleep(5)
            self.webdriver.find_element_by_xpath(
                "//div[contains(@class ,'text ng-binding') and contains(@ng-bind,'i.value')]"
            ).click()
            sleep(5)
            self.webdriver.find_element_by_xpath(
                "//div[contains(@class ,'ng-binding ng-scope') and contains(text(),'OR')]"
            ).click()

            audience_page.save_and_create_button().click()
            sleep(10)
            # Navigating to home screen
            self.webdriver.switch_to_default_content()
            home_page.lbl_Audience_Explorer_omni().click()
            sleep(10)
            iframe = self.webdriver.find_elements_by_tag_name('iframe')[0]
            self.webdriver.switch_to.frame(iframe)
            new_project_name = project_name
    def test_population_female(self):
        country = self.configAB["Conceptual"]["country"]
        project_name = self.configAB["Conceptual"]["project_name"]
        ds_type = "Advanced Audience Data"

        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects(project_name)
        proj_page = ProjectPage(self.webdriver, self.config)
        proj_page.add_audience_button().click()

        audience_page = AudiencePage(self.webdriver, self.config)
        audience_page.add_dataSource(ds_type)
        audience_page.create_advanced_audience_data_criteria(
            'Demographics', 'Gender', 'Female', 'TRUE')

        audience_page.audience_name_textbox().clear()
        audience_page.audience_name_textbox().send_keys(country +
                                                        " Population Female")
        sleep(5)
        audience_page.save_and_create_button().click()
    def test_MSOA_MSAA(self):
        country = self.configAB["Conceptual"]["country"]
        project_name = self.configAB["Conceptual"]["project_name"]
        ds_type = "Advanced Audience Data"

        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects(project_name)
        proj_page = ProjectPage(self.webdriver, self.config)
        # proj_page.add_audience_button().click()
        #
        # audience_page = AudiencePage(self.webdriver, self.config)
        # audience_page.add_dataSource(ds_type)
        # audience_page.create_advanced_audience_data_criteria_multiple_attribute_value('In-Market Audiences', 'Automotive & Vehicles', 'Car Classifications', value=['Luxury SUV', 'Luxury Sedan'])
        # audience_page.add_dataSource(ds_type)
        # audience_page.create_browsing_behaviour_domain_names_multiple(name=['acura.com', 'lexus.com', 'bmw.com'])
        # audience_page.add_dataSource(ds_type)
        # audience_page.create_browsing_behaviour_domain_names_multiple(name=['acura.com', 'lexus.com', 'bmw.com'])
        # audience_page.audience_name_textbox().clear()
        # audience_page.audience_name_textbox().send_keys(country + " MSOA-Lux Auto-JS or Lotm")
        # sleep(5)
        # audience_page.save_and_create_button().click()
        # ###############################################
        sleep(5)
        proj_page.add_audience_button().click()

        audience_page = AudiencePage(self.webdriver, self.config)
        audience_page.add_dataSource(ds_type)
        audience_page.create_advanced_audience_data_criteria(
            'Demographics', 'Number of Children', '1 OR MORE', 'TRUE')
        audience_page.add_dataSource('Browsing Behavior')
        audience_page.create_browsing_behaviour_domain_names_multiple(
            name=['acura.com', 'lexus.com', 'bmw.com'])
        # audience_page.add_dataSource(ds_type)
        # audience_page.create_browsing_behaviour_domain_names_multiple(name=['acura.com', 'lexus.com', 'bmw.com'])
        audience_page.audience_name_textbox().clear()
        audience_page.audience_name_textbox().send_keys(
            country + " MSAA-Lux Auto w  Kids-JS or Lotm")
        sleep(5)
        audience_page.save_and_create_button().click()
Example #8
0
    def test_create_advance_data_audiences(self):
        # project_name = self.configAB["Lotame_Viz"]["project_name"]
        # path = os.path.join('testdata', 'sidebar.json')
        # print("location:" + path)

        proj_page = ProjectPage(self.webdriver, self.config)
        audience_page = AudiencePage(self.webdriver, self.config)
        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects("Test_US_Automation")
        sleep(10)
        # Audience Creation using Advanced Audience Data
        proj_page.add_audience_button().click()
        sleep(5)
        audience_page.audience_name_textbox().send_keys('Advance_Audience')
        audience_page.add_dataSource('Advanced Audience Data')
        source = self.webdriver.find_element_by_xpath(
            "//div[contains(@class,'header-label ng-binding ui-draggable-handle') and contains(text(),'Advanced Audience Data Criteria')]"
        )
        target = self.webdriver.find_element_by_xpath(
            "//div[contains(@class, 'criteria-panel-header') and contains(text(),'Define Your Audience')]"
        )
        mouse = ActionChains(self.webdriver)
        mouse.drag_and_drop(source, target).perform()
        audience_page.create_advanced_audience_data_criteria(
            'Food', 'Diet', 'Vegan', '3 Average')
        audience_page.add_criteria_plusicon().click()
        audience_page.create_advanced_audience_data_criteria(
            'Demographic', 'Education', 'Education - Head of Household',
            'Completed College')
        sleep(5)
        self.webdriver.find_element_by_xpath(
            "//div[contains(@class ,'text ng-binding') and contains(@ng-bind,'i.value')]"
        ).click()
        sleep(5)
        self.webdriver.find_element_by_xpath(
            "//div[contains(@class ,'ng-binding ng-scope') and contains(text(),'OR')]"
        ).click()
        audience_page.save_and_create_button().click()
        sleep(10)
Example #9
0
    def test_create_MSSA_IG_and(self):
        country = self.configAB["Conceptual"]["country"]
        project_name = self.configAB["Conceptual"]["project_name"]

        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects(project_name)
        proj_page = ProjectPage(self.webdriver, self.config)
        proj_page.add_audience_button().click()

        audience_page = AudiencePage(self.webdriver, self.config)
        audience_page.add_dataSource('Browsing Behavior')
        audience_page.create_browsing_behaviour_domain_names('instagram.com')
        sleep(5)
        audience_page.add_dataSource('Advanced Audience Data')
        audience_page.create_advanced_audience_data_criteria(
            'Affinity Audiences', 'Digital Engagement', 'Social Media',
            'Instagram')
        audience_page.audience_name_textbox().clear()
        audience_page.audience_name_textbox().send_keys(
            country + " MSOA - IG - JS and Lotm")
        sleep(5)
        audience_page.save_and_create_button().click()
    def test_create_audience_population(self):
        country = self.configAB["Conceptual"]["country"]
        project_name = self.configAB["Conceptual"]["project_name"]
        ds_type = "Advanced Audience Data"

        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects(project_name)

        for age_range in ['18-24', '25-34', '35-44', '45-54', '55-64', '65+']:
            proj_page = ProjectPage(self.webdriver, self.config)
            proj_page.add_audience_button().click()

            audience_page = AudiencePage(self.webdriver, self.config)
            audience_page.add_dataSource(ds_type)
            # audience_page.create_advanced_audience_data_criteria('Demographics', 'Age', age_range, 'TRUE')
            audience_page.create_advanced_audience_data_criteria(
                'Demographics', 'Age', 'Age Group', age_range)

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(country +
                                                            " Population " +
                                                            age_range)
            sleep(5)
            audience_page.save_and_create_button().click()
    def test_all(self):
        country = self.configAB["Conceptual"]["country"]
        project_name = self.configAB["Conceptual"]["project_name"]
        ds_type = "Browsing Behavior"

        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects(project_name)
        proj_page = ProjectPage(self.webdriver, self.config)
        proj_page.add_audience_button().click()
        audience_page = AudiencePage(self.webdriver, self.config)
        try:
            audience_page.add_dataSource(ds_type)
            # audience_page.create_browsing_behaviour_domain_categories_multiple_sub_category('Social Media',sub_category=['Blogs','Social Networking'])
            audience_page.create_browsing_behaviour_domain_categories_single_sub_category(
                'Social Media', 'Blogs')
            audience_page.add_dataSource(ds_type)
            audience_page.create_browsing_behaviour_domain_categories_single_sub_category(
                'Social Media', 'Social Networking')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " SSA - Any Social - JS")
            sleep(10)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSA - Any Social - JS")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_browsing_behaviour_domain_names(
                'facebook.com')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(country +
                                                            " SSA - FB - JS")
            sleep(10)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSA - FB - JS")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_browsing_behaviour_domain_names(
                'instagram.com')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(country +
                                                            " SSA - IG - JS")
            sleep(10)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSA - IG - JS")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_browsing_behaviour_domain_names(
                'facebook.com')

            audience_page.inner_criteria_plusIcon().click()
            audience_page.create_browsing_behaviour_domain_names(
                'instagram.com')
            list = self.webdriver.find_elements_by_xpath(
                "//div[contains(@class,'criteria-oper')]/div[text()='AND']")
            list[1].click()
            self.webdriver.find_element_by_xpath("//div[text()='OR']").click()

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " SSOA - FB,IG - JS")
            sleep(10)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSOA - FB,IG - JS")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_browsing_behaviour_domain_names(
                'facebook.com')

            audience_page.add_dataSource(ds_type)
            audience_page.create_browsing_behaviour_domain_names(
                'instagram.com')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " SSAA - FB & IG - JS")
            sleep(10)
            audience_page.save_and_create_button().click()

        except Exception as e:
            print(e, country + " SSAA - FB & IG - JS")
            audience_page.aud_back_arrow().click()

        ######################Lotame#######################

        ###################################################

        ds_type = "Advanced Audience Data"
        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria(
                'In-Market Audiences', 'Automotive & Vehicles', 'Cars', 'TRUE')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " SSA-Auto In Market-Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
            ###############################################
        except Exception as e:
            print(e, country + " SSA-Auto In Market-Lotm")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria_multiple_attribute_value(
                'In-Market Audiences',
                'Automotive & Vehicles',
                'Car Classifications',
                value=['Luxury SUV', 'Luxury Sedan'])

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " SSOA-Lux Auto In Market-Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSOA-Lux Auto In Market-Lotm")
            audience_page.aud_back_arrow().click()
            ###############################################
        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria_multiple_attribute_value(
                'In-Market Audiences',
                'Automotive & Vehicles',
                'Car Classifications',
                value=['Luxury SUV', 'Luxury Sedan'])
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria_multiple_attribute_value(
                'Purchase History',
                'Automotive & Vehicles',
                'Car Classifications',
                value=['Luxury SUV', 'Luxury Sedan'])

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " SSAA-Lux Auto InMarket & Own-Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSAA-Lux Auto InMarket & Own-Lotm")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Any Social Media')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " SSA Any Social - Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSA Any Social - Lotm")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria(
                'Demographics', 'Gender', 'Male', 'TRUE')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(country +
                                                            " Population Male")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " Population Male")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria(
                'Demographics', 'Gender', 'Female', 'TRUE')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " Population Female")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " Population Female")
            audience_page.aud_back_arrow().click()

        ######################################

        for age_range in ['18-24', '25-34', '35-44', '45-54', '55-64', '65+']:
            try:
                proj_page = ProjectPage(self.webdriver, self.config)
                proj_page.add_audience_button().click()

                audience_page.add_dataSource(ds_type)
                # audience_page.create_advanced_audience_data_criteria('Demographics', 'Age', age_range, 'TRUE')
                audience_page.create_advanced_audience_data_criteria(
                    'Demographics', 'Age', 'Age Group', age_range)

                audience_page.audience_name_textbox().clear()
                audience_page.audience_name_textbox().send_keys(
                    country + " Population " + age_range)
                sleep(5)
                audience_page.save_and_create_button().click()
            except Exception as e:
                print(e, country + " Population " + age_range)
                audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Facebook')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(country +
                                                            " SSA - FB - Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSA - FB - Lotm")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Instagram')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(country +
                                                            " SSA - IG - Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSA - IG - Lotm")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Facebook')
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Instagram')

            list = self.webdriver.find_elements_by_xpath(
                "//div[contains(@class,'criteria-oper')]/div[text()='AND']")
            list[1].click()
            self.webdriver.find_element_by_xpath("//div[text()='OR']").click()

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " SSOA - FB,IG - Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSOA - FB,IG - Lotm")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Facebook')
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Instagram')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " SSAA - FB & IG - Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSAA - FB & IG - Lotm")
            audience_page.aud_back_arrow().click()

        #################################################

        ##################jumpshot-lotame################

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource('Browsing Behavior')
            audience_page.create_browsing_behaviour_domain_names(
                'facebook.com')

            sleep(5)
            audience_page.add_dataSource('Advanced Audience Data')
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Facebook')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " MSSA - FB - JS and Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " MSSA - FB - JS and Lotm")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource('Browsing Behavior')
            audience_page.create_browsing_behaviour_domain_names(
                'instagram.com')
            sleep(5)
            audience_page.add_dataSource('Advanced Audience Data')
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Instagram')
            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " MSAA - IG - JS and Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " MSAA - IG - JS and Lotm")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource('Browsing Behavior')
            audience_page.create_browsing_behaviour_domain_names(
                'facebook.com')
            sleep(5)
            audience_page.add_dataSource('Advanced Audience Data')
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Facebook')
            list = self.webdriver.find_elements_by_xpath(
                "//div[contains(@class,'criteria-oper-groups')]/div[text()='AND']"
            )
            list[1].click()
            self.webdriver.find_element_by_xpath("//div[text()='OR']").click()

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " MSOA - FB - JS or Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " MSOA - FB - JS or Lotm")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource('Browsing Behavior')
            audience_page.create_browsing_behaviour_domain_names(
                'instagram.com')
            sleep(5)
            audience_page.add_dataSource('Advanced Audience Data')
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Instagram')
            list = self.webdriver.find_elements_by_xpath(
                "//div[contains(@class,'criteria-oper-groups')]/div[text()='AND']"
            )
            list[1].click()
            self.webdriver.find_element_by_xpath("//div[text()='OR']").click()

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " MSOA - IG - JS or Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " MSOA - IG - JS or Lotm")
            audience_page.aud_back_arrow().click()
    def test_prod_aud(self):
        country = self.configAB["Conceptual"]["country"]
        project_name = self.configAB["Conceptual"]["project_name"]
        ds_type = "Advanced Audience Data"

        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects(project_name)
        proj_page = ProjectPage(self.webdriver, self.config)
        audience_page = AudiencePage(self.webdriver, self.config)


        try:
            proj_page = ProjectPage(self.webdriver, self.config)
            proj_page.add_audience_button().click()

            audience_page.add_dataSource(ds_type)
            # audience_page.create_advanced_audience_data_criteria('Demographics', 'Age', age_range, 'TRUE')
            audience_page.create_advanced_audience_data_criteria('Demographics', 'Age', 'Age Group', '18-24')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(country + " Population " + '18-24')
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " Population " + '18-24')
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource('Browsing Behavior')
            # audience_page.create_browsing_behaviour_domain_categories_multiple_sub_category('Social Media',sub_category=['Blogs','Social Networking'])
            audience_page.create_browsing_behaviour_domain_categories_single_sub_category('Social Media', 'Blogs')
            audience_page.add_dataSource('Browsing Behavior')
            audience_page.create_browsing_behaviour_domain_categories_single_sub_category('Social Media', 'Social Networking')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(country + " SSA - Any Social - JS")
            sleep(10)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSA - Any Social - JS")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource('Browsing Behavior')
            audience_page.create_browsing_behaviour_domain_names('facebook.com')

            audience_page.inner_criteria_plusIcon().click()
            audience_page.create_browsing_behaviour_domain_names('instagram.com')
            list = self.webdriver.find_elements_by_xpath("//div[contains(@class,'criteria-oper')]/div[text()='AND']")
            list[1].click()
            self.webdriver.find_element_by_xpath("//div[text()='OR']").click()

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(country + " SSOA - FB,IG - JS")
            sleep(10)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSOA - FB,IG - JS")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource('Browsing Behavior')
            audience_page.create_browsing_behaviour_domain_names('facebook.com')
            sleep(5)
            audience_page.add_dataSource('Advanced Audience Data')
            audience_page.create_advanced_audience_data_criteria('Affinity Audiences', 'Digital Engagement', 'Social Media',
                                                                 'Facebook')
            list = self.webdriver.find_elements_by_xpath("//div[contains(@class,'criteria-oper-groups')]/div[text()='AND']")
            list[1].click()
            self.webdriver.find_element_by_xpath("//div[text()='OR']").click()

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(country + " MSOA - FB - JS or Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " MSOA - FB - JS or Lotm")
            audience_page.aud_back_arrow().click()
    def test_all(self):
        country = self.configAB["Conceptual"]["country"]
        project_name = self.configAB["Conceptual"]["project_name"]
        ds_type = "Advanced Audience Data"

        home_page = HomePage(self.webdriver, self.config)
        home_page.searchProjects(project_name)
        proj_page = ProjectPage(self.webdriver, self.config)
        proj_page.add_audience_button().click()
        audience_page = AudiencePage(self.webdriver, self.config)
        try:
            audience_page.add_dataSource(ds_type)
            audience_page.create_advanced_audience_data_criteria_multiple_attribute_value(
                'In-Market Audiences',
                'Automotive & Vehicles',
                'Car Classifications',
                value=['Luxury SUV', 'Luxury Sedan'])

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " SSOA-Lux Auto In Market-Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSOA-Lux Auto In Market-Lotm")
            audience_page.aud_back_arrow().click()
            ###############################################
        try:
            proj_page.add_audience_button().click()

            audience_page.add_dataSource(ds_type)
            # audience_page.create_advanced_audience_data_criteria('Demographics', 'Age', '18-24', 'TRUE')
            audience_page.create_advanced_audience_data_criteria(
                'Demographics', 'Age', 'Age Group', '18-24')

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(country +
                                                            " Population " +
                                                            '18-24')
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " Population 18-24")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource('Browsing Behavior')
            audience_page.create_browsing_behaviour_domain_categories_multiple_sub_category(
                'Social Media', sub_category=['Blogs', 'Social Networking'])

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " SSA - Any Social - JS")
            sleep(10)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " SSA - Any Social - JS")
            audience_page.aud_back_arrow().click()

        try:
            proj_page.add_audience_button().click()
            audience_page.add_dataSource('Browsing Behavior')
            audience_page.create_browsing_behaviour_domain_names(
                'instagram.com')
            sleep(5)
            audience_page.add_dataSource('Advanced Audience Data')
            audience_page.create_advanced_audience_data_criteria(
                'Affinity Audiences', 'Digital Engagement', 'Social Media',
                'Instagram')
            list = self.webdriver.find_elements_by_xpath(
                "//div[contains(@class,'criteria-oper-groups')]/div[text()='AND']"
            )
            list[1].click()
            self.webdriver.find_element_by_xpath("//div[text()='OR']").click()

            audience_page.audience_name_textbox().clear()
            audience_page.audience_name_textbox().send_keys(
                country + " MSOA - IG - JS or Lotm")
            sleep(5)
            audience_page.save_and_create_button().click()
        except Exception as e:
            print(e, country + " MSOA - IG - JS or Lotm")
            audience_page.aud_back_arrow().click()
    def test_create_other_audiences(self):
        project_name = self.configAB["Lotame_Viz"]["project_name"]
        path = os.path.join('testdata', 'sidebar.json')
        print("location:" + path)

        proj_page = ProjectPage(self.webdriver, self.config)
        audience_page = AudiencePage(self.webdriver, self.config)
        home_page = HomePage(self.webdriver, self.config)

        with open(path) as file:
            data = json.load(file)
        for item in range(len(data)):
            link = data[item]["link"]
            #Project selection
            new_project_name = project_name + '_' + link
            print(new_project_name)
            sleep(5)
            home_page.searchProjects(new_project_name)
            sleep(10)
            #Audience Creation
            proj_page.add_audience_button().click()
            sleep(5)
            audience_page.audience_name_textbox().send_keys('Beauty')
            audience_page.add_dataSource('Advanced Audience Data')
            source = self.webdriver.find_element_by_xpath(
                "//div[contains(@class,'header-label ng-binding ui-draggable-handle') and contains(text(),'Advanced Audience Data Criteria')]"
            )
            target = self.webdriver.find_element_by_xpath(
                "//div[contains(@class, 'criteria-panel-header') and contains(text(),'Define Your Audience')]"
            )
            mouse = ActionChains(self.webdriver)
            mouse.drag_and_drop(source, target).perform()
            audience_page.create_advanced_audience_data_criteria(
                'In-Market Audiences', 'Beauty and Wellness', 'Personal Care',
                'Cosmetics')
            audience_page.add_criteria_plusicon().click()
            audience_page.create_advanced_audience_data_criteria(
                'In-Market Audiences', 'Beauty and Wellness', 'Personal Care',
                'Hair Care')
            # audience_page.add_criteria_plusicon().click()
            # audience_page.create_advanced_audience_data_criteria('Affinity Audiences', 'Lifestyle and Hobbies', 'Literature', 'Family Literature (Fiction)')
            # audience_page.add_criteria_plusicon().click()
            # audience_page.create_advanced_audience_data_criteria('Affinity Audiences', 'Lifestyle and Hobbies', 'Literature', 'Family Literature (Non-Fiction)')

            sleep(5)
            self.webdriver.find_element_by_xpath(
                "//div[contains(@class ,'text ng-binding') and contains(@ng-bind,'i.value')]"
            ).click()
            sleep(5)
            self.webdriver.find_element_by_xpath(
                "//div[contains(@class ,'ng-binding ng-scope') and contains(text(),'OR')]"
            ).click()

            # If you have 3 audience criteria's
            # sleep(5)
            # self.webdriver.find_element_by_xpath("//div[contains(@class ,'text ng-binding') and contains(@ng-bind,'i.value')]//following::div[contains(@class ,'text ng-binding') and contains(@ng-bind,'i.value')]").click()
            # sleep(5)
            # self.webdriver.find_element_by_xpath("//div[contains(@class ,'ng-binding ng-scope') and contains(text(),'OR')]").click()

            # If you have 4 audience criteria's
            # sleep(5)
            # self.webdriver.find_element_by_xpath("//div[contains(@class ,'text ng-binding') and contains(@ng-bind,'i.value')]//following::div[contains(@class ,'text ng-binding') and contains(@ng-bind,'i.value')]//following::div[contains(@class ,'text ng-binding') and contains(@ng-bind,'i.value')]").click()
            # sleep(5)
            # # self.webdriver.find_element_by_xpath("//div[contains(@class ,'ng-binding ng-scope') and contains(text(),'OR')]").click()
            # third_drp_value = self.webdriver.find_element_by_xpath("//div[contains(@class ,'ng-binding ng-scope') and contains(text(),'OR')]")
            # self.webdriver.execute_script("arguments[0].click();", third_drp_value)

            audience_page.save_and_create_button().click()
            sleep(10)
            # Navigating to home screen
            self.webdriver.switch_to_default_content()
            home_page.lbl_Audience_Explorer_omni().click()
            sleep(10)
            iframe = self.webdriver.find_elements_by_tag_name('iframe')[0]
            self.webdriver.switch_to.frame(iframe)
            new_project_name = project_name