コード例 #1
0
 def disconnect(self, product_page=True):
     time.sleep(2)
     if (product_page):
         ui.click(self._objects['profil'])
     else:
         ui.click(self._objects['profil_other_page'])
     time.sleep(3)
     ui.click(self._objects['logout'])
コード例 #2
0
 def connect(self, login, password):
     time.sleep(2)
     ui.set_text(self._objects['email'], login)
     ui.set_text(self._objects['password'], password)
     ui.click(self._objects['btn_connection'])
コード例 #3
0
    def search_module(self, var_test):
        """
        try:
            ui.click(("css","a.hide-button"), test=True)
        except:
            None
        """
        if var_test.get('view') == "grid":
            ui.click(self._objects['grid_view'])
            nb_modules = int(
                ui.get_text(self._objects['nb_result_search']).split(" ")[0])
            i = 1
            all_modules = []
            while i <= nb_modules:
                try:
                    def_module = ui.def_object(
                        self._objects['block_module_first'], i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                except:
                    def_module = ui.def_object(self._objects['block_module'],
                                               i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                all_modules.append(
                    (my_module.get_attribute('data-name'),
                     my_module.get_attribute('data-description'),
                     my_module.get_attribute('data-author'),
                     my_module.get_attribute('data-price'),
                     my_module.get_attribute('data-categories')))
                i = i + 1

            my_search_grid = False
            ui.set_text(self._objects['search'], var_test.get('search_name'))
            my_elem = ui.find_element(self._objects['search'][0],
                                      self._objects['search'][1])
            time.sleep(2)
            my_elem.send_keys(Keys.ENTER)
            nb_search_result = int(
                ui.get_text(self._objects['nb_result_search']).split(" ")[0])
            decomposed_search_word = var_test.get('search_name').lower().split(
                " ")

            if nb_search_result > 0:
                nb_found = 0
                for modules_search in all_modules:
                    search = False
                    for word in decomposed_search_word:
                        if word in modules_search[0].lower(
                        ) or word in modules_search[1].lower() or word.lower(
                        ) in modules_search[2].lower():
                            search = True

                    if search:
                        nb_found = nb_found + 1
                if nb_search_result == nb_found:
                    i = 1
                    check_search = 0
                    order_module = []
                    while i <= nb_search_result:
                        def_module = ui.def_object(
                            self._objects['block_module'], i)
                        my_module = ui.find_element(def_module[0],
                                                    def_module[1])
                        check_module = {}
                        order_module.append(
                            (my_module.get_attribute('data-name'),
                             my_module.get_attribute('data-description'),
                             my_module.get_attribute('data-author'),
                             my_module.get_attribute('data-price')))
                        check_module['data-name'] = my_module.get_attribute(
                            'data-name')
                        check_module[
                            'data-description'] = my_module.get_attribute(
                                'data-description')
                        check_module['data-author'] = my_module.get_attribute(
                            'data-author')

                        for var in check_module:
                            search = False
                            for word in decomposed_search_word:
                                if word in check_module.get(var).lower():
                                    search = True
                            if search:
                                check_search = check_search + 1
                                break
                        i = i + 1

                    ui.click(self._objects['cancel_search'])
                    nb_modules2 = int(
                        ui.get_text(
                            self._objects['nb_result_search']).split(" ")[0])

                    if check_search == nb_search_result and nb_modules == nb_modules2:
                        my_search_grid = True
                    else:
                        Context().logger.error(
                            "Modules found by the search not matching with the search : "
                            + var_test.get('search_name'))
                else:
                    Context().logger.error(
                        "Number of module found by the search is wrong. Number of module expected : "
                        + str(nb_search_result) +
                        " and number of module found : " + str(nb_found))
            else:
                Context().logger.warning(
                    "No module found with the following search : " +
                    var_test.get('search_name'))

            return my_search_grid

        if var_test.get('view') == "list":

            ui.click(self._objects['list_view'])
            nb_modules = int(
                ui.get_text(self._objects['nb_result_search']).split(" ")[0])
            i = 1
            all_modules = []
            while i <= nb_modules:
                try:
                    def_module = ui.def_object(
                        self._objects['list_module_first'], i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                except:
                    def_module = ui.def_object(self._objects['list_module'], i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                all_modules.append(
                    (my_module.get_attribute('data-name'),
                     my_module.get_attribute('data-description'),
                     my_module.get_attribute('data-author'),
                     my_module.get_attribute('data-price'),
                     my_module.get_attribute('data-categories')))
                i = i + 1

            my_search_list = False
            ui.set_text(self._objects['search'], var_test.get('search_name'))
            my_elem = ui.find_element(self._objects['search'][0],
                                      self._objects['search'][1])
            time.sleep(2)
            my_elem.send_keys(Keys.ENTER)
            nb_search_result = int(
                ui.get_text(self._objects['nb_result_search']).split(" ")[0])
            decomposed_search_word = var_test.get('search_name').lower().split(
                " ")
            if nb_search_result > 0:
                nb_found = 0
                for modules_search in all_modules:
                    search = False
                    for word in decomposed_search_word:
                        if word in modules_search[0].lower() or word in modules_search[1].lower() or word.lower() in \
                                modules_search[2].lower():
                            search = True

                    if search:
                        nb_found = nb_found + 1

                if nb_search_result == nb_found:
                    i = 1
                    check_search = 0
                    order_module = []
                    while i <= nb_search_result:
                        def_module = ui.def_object(
                            self._objects['list_module'], i)
                        my_module = ui.find_element(def_module[0],
                                                    def_module[1])
                        check_module = {}
                        order_module.append(
                            (my_module.get_attribute('data-name'),
                             my_module.get_attribute('data-description'),
                             my_module.get_attribute('data-author'),
                             my_module.get_attribute('data-price')))
                        check_module['data-name'] = my_module.get_attribute(
                            'data-name')
                        check_module[
                            'data-description'] = my_module.get_attribute(
                                'data-description')
                        check_module['data-author'] = my_module.get_attribute(
                            'data-author')

                        for var in check_module:
                            search = False
                            for word in decomposed_search_word:
                                if word in check_module.get(var).lower():
                                    search = True
                            if search:
                                check_search = check_search + 1
                                break
                        i = i + 1

                    ui.click(self._objects['cancel_search'])
                    nb_modules2 = int(
                        ui.get_text(
                            self._objects['nb_result_search']).split(" ")[0])

                    if check_search == nb_search_result and nb_modules == nb_modules2:
                        my_search_list = True
                    else:
                        Context().logger.error(
                            "Modules found by the search not matching with the search : "
                            + var_test.get('search_name'))
                else:
                    Context().logger.error(
                        "Number of module found by the search is wrong. Number of module expected : "
                        + str(nb_search_result) +
                        " and number of module found : " + str(nb_found))
            else:
                Context().logger.warning(
                    "No module found with the following search : " +
                    var_test.get('search_name'))

            #Go to installed modules and make a search
            try:
                ui.click(self._objects['tab_installed_modules'])

                i = 1

                def_module = ui.def_object(
                    self._objects['installed_list_first_module'], i)
                first_installed_module = ui.find_element(
                    def_module[0], def_module[1])

                check_module = {}
                check_module[
                    'data-name'] = first_installed_module.get_attribute(
                        'data-name')
                check_module[
                    'data-description'] = first_installed_module.get_attribute(
                        'data-description')
                check_module[
                    'data-author'] = first_installed_module.get_attribute(
                        'data-author')
                check_module[
                    'data-tech-name'] = first_installed_module.get_attribute(
                        'data-tech-name')

                ui.set_text(self._objects['search'],
                            check_module.get('data-tech-name'))
                my_elem = ui.find_element(self._objects['search'][0],
                                          self._objects['search'][1])
                time.sleep(2)
                my_elem.send_keys(Keys.ENTER)

                found_module = ui.find_element(def_module[0], def_module[1])
                Test.assert_equals(check_module.get('data-name'),
                                   found_module.get_attribute('data-name'),
                                   "'name' not matching", "'name' is ok")
                Test.assert_equals(
                    check_module.get('data-description'),
                    found_module.get_attribute('data-description'),
                    "'description' not matching", "'description' is ok")
                Test.assert_equals(check_module.get('data-author'),
                                   found_module.get_attribute('data-author'),
                                   "'author' not matching", "'authore' is ok")
                Test.assert_equals(
                    check_module.get('data-tech-name'),
                    found_module.get_attribute('data-tech-name'),
                    "'data-tech-name' not matching", "'data-tech-name' is ok")

                ui.click(self._objects['cancel_search'])
            except:
                my_search_list = False
                ui.click(self._objects['cancel_search'])
                raise

            return my_search_list
コード例 #4
0
 def go_to_admin_menu_by_move(self, entry, subEntry=False):
     if subEntry == False:
         ui.click(self._objects[entry])
     else:
         ui.click_submenu_by_move(self._objects[entry],
                                  self._objects[subEntry])
コード例 #5
0
    def sort_modules(self, var_test):
        """
        TODO:
        faire la seletion du tri par la position dans la liste et nom sa valeur (pb en changeant de langue)
        """
        if var_test.get('view') == "grid":
            my_order_grid = True
            """try:
                    ui.click(("css","a.hide-button"), test=True)
            except:
                None
            """
            nb_modules = int(
                ui.get_text(self._objects['nb_result_search']).split(" ")[0])
            i = 1
            all_modules = []
            while i <= nb_modules:
                try:
                    def_module = ui.def_object(
                        self._objects['block_module_first'], i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                except:
                    def_module = ui.def_object(self._objects['block_module'],
                                               i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                if my_module.get_attribute('data-name') != "":
                    all_modules.append(
                        (my_module.get_attribute('data-name'),
                         my_module.get_attribute('data-description'),
                         my_module.get_attribute('data-author'),
                         my_module.get_attribute('data-price'),
                         my_module.get_attribute('data-categories')))
                else:
                    all_modules.append(
                        (my_module.get_attribute('data-tech-name'),
                         my_module.get_attribute('data-description'),
                         my_module.get_attribute('data-author'),
                         my_module.get_attribute('data-price'),
                         my_module.get_attribute('data-categories')))
                i = i + 1
            sort_type = [('name', 0), ('price', 3), ('price-desc', 3)]
            for my_sort in sort_type:
                sort_def = ui.def_object(self._objects['sort_type'],
                                         my_sort[0])
                ui.click(sort_def)
                time.sleep(2)
                if "price" in my_sort[0]:
                    j = 1
                    old_module_price = ""
                    while j <= nb_modules:
                        try:
                            def_module = ui.def_object(
                                self._objects['block_module_first'], j)
                            my_module = ui.find_element(
                                def_module[0], def_module[1])
                        except:
                            try:
                                def_module = ui.def_object(
                                    self._objects['block_module'], j + 1)
                                my_module = ui.find_element(
                                    def_module[0], def_module[1])
                            except:
                                my_order_grid = False
                                raise
                        if old_module_price == "":
                            old_module_price = my_module.get_attribute(
                                'data-price')
                        if "desc" in my_sort[0]:
                            try:
                                Test.assert_less_or_equal(
                                    float(old_module_price),
                                    float(
                                        my_module.get_attribute('data-price')),
                                    "order " + my_sort[0] + " is not correct",
                                    "order " + my_sort[0] +
                                    " is correct ,,,, values: " +
                                    str(old_module_price) + "//" +
                                    str(my_module.get_attribute('data-price')))
                                old_module_price = my_module.get_attribute(
                                    'data-price')
                            except:
                                my_order_grid = False
                                raise
                        else:
                            try:
                                Test.assert_more_or_equal(
                                    float(old_module_price),
                                    float(
                                        my_module.get_attribute('data-price')),
                                    "order " + my_sort[0] + " is not correct",
                                    "order " + my_sort[0] +
                                    " is correct ,,,, values: " +
                                    str(old_module_price) + "//" +
                                    str(my_module.get_attribute('data-price')))
                                old_module_price = my_module.get_attribute(
                                    'data-price')
                            except:
                                my_order_grid = False
                                raise
                        j = j + 1
                else:
                    all_modules = sorted(
                        all_modules,
                        key=lambda colonnes: colonnes[int(my_sort[1])].lower())
                    i = 0
                    while i < nb_modules:
                        try:
                            def_module = ui.def_object(
                                self._objects['block_module_first'], i + 1)
                            my_module = ui.find_element(
                                def_module[0], def_module[1])
                        except:
                            try:
                                def_module = ui.def_object(
                                    self._objects['block_module'], i + 1)
                                my_module = ui.find_element(
                                    def_module[0], def_module[1])
                            except:
                                my_order_grid = False
                                raise
                        if my_module.get_attribute('data-name') != "":
                            try:
                                Test.assert_equals(
                                    all_modules[i][0],
                                    my_module.get_attribute('data-name'),
                                    "'name' not matching", "'name' is ok")
                                Test.assert_equals(
                                    all_modules[i][1],
                                    my_module.get_attribute(
                                        'data-description'),
                                    "'description' not matching",
                                    "'description' is ok")
                                Test.assert_equals(
                                    all_modules[i][2],
                                    my_module.get_attribute('data-author'),
                                    "'author' not matching", "'author' is ok")
                                Test.assert_equals(
                                    all_modules[i][3],
                                    my_module.get_attribute('data-price'),
                                    "'price' not matching", "'price' is ok")
                            except:
                                Context().logger.error(
                                    "Issue with the order function")
                                my_order_grid = False
                                raise
                        else:
                            Test.assert_equals(
                                all_modules[i][0],
                                my_module.get_attribute('data-tech-name'),
                                "'name' not matching", "'name' is ok")
                        i = i + 1

            return my_order_grid

        if var_test.get('view') == "list":
            my_order_list = True
            """
            try:
                    ui.click(("css","a.hide-button"), test=True)
            except:
                None
            """
            ui.click(self._objects['list_view'])
            nb_modules = int(
                ui.get_text(self._objects['nb_result_search']).split(" ")[0])
            i = 1
            all_modules = []
            while i <= nb_modules:
                try:
                    def_module = ui.def_object(
                        self._objects['list_module_first'], i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                except:
                    def_module = ui.def_object(self._objects['list_module'], i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                if my_module.get_attribute('data-name') != "":
                    all_modules.append(
                        (my_module.get_attribute('data-name'),
                         my_module.get_attribute('data-description'),
                         my_module.get_attribute('data-author'),
                         my_module.get_attribute('data-price'),
                         my_module.get_attribute('data-categories')))
                else:
                    all_modules.append(
                        (my_module.get_attribute('data-tech-name'),
                         my_module.get_attribute('data-description'),
                         my_module.get_attribute('data-author'),
                         my_module.get_attribute('data-price'),
                         my_module.get_attribute('data-categories')))
                i = i + 1
            sort_type = [('name', 0), ('price', 3), ('price-desc', 3)]
            for my_sort in sort_type:
                sort_def = ui.def_object(self._objects['sort_type'],
                                         my_sort[0])
                ui.click(sort_def)
                time.sleep(2)
                if "price" in my_sort[0]:
                    j = 1
                    old_module_price = ""
                    while j <= nb_modules:
                        try:
                            def_module = ui.def_object(
                                self._objects['list_module_first'], j)
                            my_module = ui.find_element(
                                def_module[0], def_module[1])
                        except:
                            try:
                                def_module = ui.def_object(
                                    self._objects['list_module'], j + 1)
                                my_module = ui.find_element(
                                    def_module[0], def_module[1])
                            except:
                                my_order_list = False
                                raise
                        if old_module_price == "":
                            old_module_price = my_module.get_attribute(
                                'data-price')
                        if "desc" in my_sort[0]:
                            try:
                                Test.assert_less_or_equal(
                                    float(old_module_price),
                                    float(
                                        my_module.get_attribute('data-price')),
                                    "order " + my_sort[0] + " is not correct",
                                    "order " + my_sort[0] +
                                    " is correct ,,,, values: " +
                                    str(old_module_price) + "//" +
                                    str(my_module.get_attribute('data-price')))
                                old_module_price = my_module.get_attribute(
                                    'data-price')
                            except:
                                my_order_list = False
                                raise
                        else:
                            try:
                                Test.assert_more_or_equal(
                                    float(old_module_price),
                                    float(
                                        my_module.get_attribute('data-price')),
                                    "order " + my_sort[0] + " is not correct",
                                    "order " + my_sort[0] +
                                    " is correct ,,,, values: " +
                                    str(old_module_price) + "//" +
                                    str(my_module.get_attribute('data-price')))
                                old_module_price = my_module.get_attribute(
                                    'data-price')
                            except:
                                my_order_list = False
                                raise
                        j = j + 1
                else:
                    all_modules = sorted(
                        all_modules,
                        key=lambda colonnes: colonnes[int(my_sort[1])].lower())
                    i = 0
                    while i < nb_modules:
                        try:
                            def_module = ui.def_object(
                                self._objects['list_module_first'], i + 1)
                            my_module = ui.find_element(
                                def_module[0], def_module[1])
                        except:
                            try:
                                def_module = ui.def_object(
                                    self._objects['list_module'], i + 1)
                                my_module = ui.find_element(
                                    def_module[0], def_module[1])
                            except:
                                my_order_list = False
                                raise
                        if my_module.get_attribute('data-name') != "":
                            try:
                                Test.assert_equals(
                                    all_modules[i][0],
                                    my_module.get_attribute('data-name'),
                                    "'name' not matching", "'name' is ok")
                                Test.assert_equals(
                                    all_modules[i][1],
                                    my_module.get_attribute(
                                        'data-description'),
                                    "'description' not matching",
                                    "'description' is ok")
                                Test.assert_equals(
                                    all_modules[i][2],
                                    my_module.get_attribute('data-author'),
                                    "'author' not matching", "'author' is ok")
                                Test.assert_equals(
                                    all_modules[i][3],
                                    my_module.get_attribute('data-price'),
                                    "'price' not matching", "'price' is ok")
                            except:
                                Context().logger.error(
                                    "Issue with the order function")
                                my_order_grid = False
                                raise
                        else:
                            Test.assert_equals(
                                all_modules[i][0],
                                my_module.get_attribute('data-tech-name'),
                                "'name' not matching", "'name' is ok")
                        i = i + 1

            #Go to installed modules and make a sort by name
            #my_order_list = True
            try:
                #ui.wait_until(self._objects['tab_installed_modules'], 60, 1)
                ui.click(self._objects['tab_installed_modules'])

                #save of installed modules
                def_object = ui.def_object(
                    self._objects['installed_modules_nb_result_search'], 1)
                number_of_modules = int(
                    ui.get_text((def_object[0], def_object[1])).split(" ")[0])

                if (number_of_modules > 1):

                    all_installed_modules = []
                    for i in range(1, number_of_modules + 1):
                        try:
                            def_module = ui.def_object(
                                self._objects['installed_list_module_first'],
                                1)
                            my_module = ui.find_element(
                                def_module[0], def_module[1])
                        except:
                            def_module = ui.def_object(
                                self._objects['installed_list_module'], 1, i)
                            my_module = ui.find_element(
                                def_module[0], def_module[1])
                        if my_module.get_attribute('data-name') != "":
                            all_installed_modules.append(
                                (my_module.get_attribute('data-name'),
                                 my_module.get_attribute('data-description'),
                                 my_module.get_attribute('data-author'),
                                 my_module.get_attribute('data-price'),
                                 my_module.get_attribute('data-categories')))
                        else:
                            all_installed_modules.append(
                                (my_module.get_attribute('data-tech-name'),
                                 my_module.get_attribute('data-description'),
                                 my_module.get_attribute('data-author'),
                                 my_module.get_attribute('data-price'),
                                 my_module.get_attribute('data-categories')))
                        i = i + 1

                #save of built-in modules
                def_object2 = ui.def_object(
                    self._objects['installed_modules_nb_result_search'], 2)
                number_of_modules2 = int(
                    ui.get_text(
                        (def_object2[0], def_object2[1])).split(" ")[0])

                if (number_of_modules2 > 1):

                    all_built_in_modules = []
                    for j in range(1, number_of_modules2 + 1):
                        try:
                            def_module = ui.def_object(
                                self._objects['installed_list_module_first'],
                                2)
                            my_module = ui.find_element(
                                def_module[0], def_module[1])
                        except:
                            def_module = ui.def_object(
                                self._objects['installed_list_module'], 2, j)
                            my_module = ui.find_element(
                                def_module[0], def_module[1])
                        if my_module.get_attribute('data-name') != "":
                            all_built_in_modules.append(
                                (my_module.get_attribute('data-name'),
                                 my_module.get_attribute('data-description'),
                                 my_module.get_attribute('data-author'),
                                 my_module.get_attribute('data-price'),
                                 my_module.get_attribute('data-categories')))
                        else:
                            all_built_in_modules.append(
                                (my_module.get_attribute('data-tech-name'),
                                 my_module.get_attribute('data-description'),
                                 my_module.get_attribute('data-author'),
                                 my_module.get_attribute('data-price'),
                                 my_module.get_attribute('data-categories')))
                        j = j + 1

                #save of theme modules
                def_object3 = ui.def_object(
                    self._objects['installed_modules_nb_result_search'], 3)
                number_of_modules3 = int(
                    ui.get_text(
                        (def_object3[0], def_object3[1])).split(" ")[0])

                if (number_of_modules3 > 1):

                    all_theme_modules = []
                    for k in range(1, number_of_modules3 + 1):
                        try:
                            def_module = ui.def_object(
                                self._objects['installed_list_module_first'],
                                3)
                            my_module = ui.find_element(
                                def_module[0], def_module[1])
                        except:
                            def_module = ui.def_object(
                                self._objects['installed_list_module'], 3, k)
                            my_module = ui.find_element(
                                def_module[0], def_module[1])
                        if my_module.get_attribute('data-name') != "":
                            all_theme_modules.append(
                                (my_module.get_attribute('data-name'),
                                 my_module.get_attribute('data-description'),
                                 my_module.get_attribute('data-author'),
                                 my_module.get_attribute('data-price'),
                                 my_module.get_attribute('data-categories')))
                        else:
                            all_theme_modules.append(
                                (my_module.get_attribute('data-tech-name'),
                                 my_module.get_attribute('data-description'),
                                 my_module.get_attribute('data-author'),
                                 my_module.get_attribute('data-price'),
                                 my_module.get_attribute('data-categories')))
                        k = k + 1

                my_sort = ui.def_object(self._objects['sort_type'], 'name')
                ui.click(my_sort)
                for a in range(1, 4):
                    #installed modules
                    if (number_of_modules > 1):

                        all_installed_modules = sorted(
                            all_installed_modules,
                            key=lambda colonnes: colonnes[0].lower())
                        for i in range(1, number_of_modules):
                            try:
                                def_module = ui.def_object(
                                    self.
                                    _objects['installed_list_module_first'], 1)
                                my_module = ui.find_element(
                                    def_module[0], def_module[1])
                            except:
                                def_module = ui.def_object(
                                    self._objects['installed_list_module'], 1,
                                    i)
                                my_module = ui.find_element(
                                    def_module[0], def_module[1])
                            if my_module.get_attribute('data-name') != "":
                                Test.assert_equals(
                                    all_installed_modules[i - 1][0],
                                    my_module.get_attribute('data-name'),
                                    "'name' not matching", "'name' is ok")
                            else:
                                Test.assert_equals(
                                    all_installed_modules[i - 1][0],
                                    my_module.get_attribute('data-tech-name'),
                                    "'name' not matching", "'name' is ok")
                            i = i + 1

                    #built-in modules
                    if (number_of_modules2 > 1):

                        all_built_in_modules = sorted(
                            all_built_in_modules,
                            key=lambda colonnes: colonnes[0].lower())
                        for j in range(1, number_of_modules2):
                            try:
                                def_module = ui.def_object(
                                    self.
                                    _objects['installed_list_module_first'], 2)
                                my_module = ui.find_element(
                                    def_module[0], def_module[1])
                            except:
                                def_module = ui.def_object(
                                    self._objects['installed_list_module'], 2,
                                    j)
                                my_module = ui.find_element(
                                    def_module[0], def_module[1])
                            if my_module.get_attribute('data-name') != "":
                                Test.assert_equals(
                                    all_built_in_modules[j - 1][0],
                                    my_module.get_attribute('data-name'),
                                    "'name' not matching", "'name' is ok")
                            else:
                                Test.assert_equals(
                                    all_built_in_modules[j - 1][0],
                                    my_module.get_attribute('data-tech-name'),
                                    "'name' not matching", "'name' is ok")
                            j = j + 1

                    #theme modules
                    if (number_of_modules3 > 1):

                        all_theme_modules = sorted(
                            all_theme_modules,
                            key=lambda colonnes: colonnes[0].lower())
                        for k in range(1, number_of_modules3):
                            try:
                                def_module = ui.def_object(
                                    self.
                                    _objects['installed_list_module_first'], 3)
                                my_module = ui.find_element(
                                    def_module[0], def_module[1])
                            except:
                                def_module = ui.def_object(
                                    self._objects['installed_list_module'], 3,
                                    k)
                                my_module = ui.find_element(
                                    def_module[0], def_module[1])
                            if my_module.get_attribute('data-name') != "":
                                Test.assert_equals(
                                    all_theme_modules[k - 1][0],
                                    my_module.get_attribute('data-name'),
                                    "'name' not matching", "'name' is ok")
                            else:
                                Test.assert_equals(
                                    all_theme_modules[k - 1][0],
                                    my_module.get_attribute('data-tech-name'),
                                    "'name' not matching", "'name' is ok")
                            k = k + 1
            except:
                my_order_list = False
                raise

            return my_order_list
コード例 #6
0
    def check_categorie(self, var_test):
        my_check_block = False
        """
        try:
                ui.click(("css","a.hide-button"), test=True)
        except:
            None
        """
        if var_test.get('view') == "grid":
            ui.click(self._objects['grid_view'])
            nb_modules = int(
                ui.get_text(self._objects['nb_result_search']).split(" ")[0])
            i = 1
            all_modules = []
            while i <= nb_modules:
                try:
                    def_module = ui.def_object(
                        self._objects['block_module_first'], i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                except:
                    def_module = ui.def_object(self._objects['block_module'],
                                               i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                all_modules.append(
                    (my_module.get_attribute('data-name'),
                     my_module.get_attribute('data-description'),
                     my_module.get_attribute('data-author'),
                     my_module.get_attribute('data-price'),
                     my_module.get_attribute('data-categories')))
                i = i + 1
            ui.click(self._objects['list_categories'])
            all_categories = ui.find_elements(
                self._objects['name_categories'][0],
                self._objects['name_categories'][1])
            ui.click(self._objects['list_categories'])
            j = 0
            total = 0
            for cat in all_categories:
                my_categorie = ui.def_object(self._objects['categorie'], j + 1)
                ui.click(self._objects['list_categories'])
                ui.click(my_categorie)
                ui.click(self._objects['cancel_search'])
                nb_result = int(
                    ui.get_text(
                        self._objects['nb_result_search']).split(" ")[0])
                nb_found = 0
                for modules_search in all_modules:
                    if modules_search[4] == cat.get_attribute(
                            'data-category-ref'):
                        nb_found = nb_found + 1

                if nb_found != nb_result:
                    if cat.get_attribute('data-category-ref') == None:
                        Context().logger.error("Cannot find the category")
                    else:
                        Context().logger.error(
                            "Issue to find the right modules for the category: "
                            + cat.get_attribute('data-category-ref') +
                            ", nb result filtered = " + str(nb_result) +
                            " and nb found module = " + str(nb_found))
                else:
                    total = total + nb_found
                j = j + 1

            ui.click(self._objects['list_categories'])
            ui.click(self._objects['reset_category_filter'])

            if total == nb_modules:
                my_check_block = True
            else:
                Context().logger.error(
                    "Total of categories modules and modules number are not equal!!"
                )

            return my_check_block

        if var_test.get('view') == "list":
            ui.click(self._objects['list_view'])
            my_check_list = False
            nb_modules = int(
                ui.get_text(self._objects['nb_result_search']).split(" ")[0])
            i = 1
            all_modules = []
            while i <= nb_modules:
                try:
                    def_module = ui.def_object(
                        self._objects['list_module_first'], i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                except:
                    def_module = ui.def_object(self._objects['list_module'], i)
                    my_module = ui.find_element(def_module[0], def_module[1])
                all_modules.append(
                    (my_module.get_attribute('data-name'),
                     my_module.get_attribute('data-description'),
                     my_module.get_attribute('data-author'),
                     my_module.get_attribute('data-price'),
                     my_module.get_attribute('data-categories')))
                i = i + 1
            ui.click(self._objects['list_categories'])
            all_categories = ui.find_elements(
                self._objects['name_categories'][0],
                self._objects['name_categories'][1])
            ui.click(self._objects['list_categories'])
            j = 0
            total = 0
            for cat in all_categories:
                my_categorie = ui.def_object(self._objects['categorie'], j + 1)
                ui.click(self._objects['list_categories'])
                ui.click(my_categorie)
                ui.click(self._objects['cancel_search'])
                nb_result = int(
                    ui.get_text(
                        self._objects['nb_result_search']).split(" ")[0])
                nb_found = 0
                for modules_search in all_modules:
                    if modules_search[4] == cat.get_attribute(
                            'data-category-ref'):
                        nb_found = nb_found + 1

                if nb_found != nb_result:
                    if cat.get_attribute('data-category-ref') == None:
                        Context().logger.error("Cannot find the category")
                    else:
                        Context().logger.error(
                            "Issue to find the right modules for the category: "
                            + cat.get_attribute('data-category-ref') +
                            ", nb result filtered = " + str(nb_result) +
                            " and nb found module = " + str(nb_found))
                else:
                    total = total + nb_found
                j = j + 1

            if total == nb_modules:
                my_check_list = True
            else:
                Context().logger.error(
                    "Total of categories modules and modules number are not equal!!"
                )

            return my_check_list
コード例 #7
0
    def install_shop(self, var_test):
        install_ok = False
        import shutil, os
        test = os.listdir(Context().environment.store_source.strip())
        test = sorted(test, reverse=True)
        test2 = []
        for my_list in test:
            if Configuration().version_presta in my_list:
                test2.append(my_list)

        test2 = sorted(test2, key=len, reverse=True)
        if test2 == []:
            my_version = Configuration().version_presta
        else:
            try:
                my_version = test2[0].split('_')[0] + "_" + str(
                    int(test2[0].split('_')[1]) + 1)
            except:
                my_version = test2[0] + "_" + "1"

        if Configuration().git == False:
            try:
                Context().logger.info(
                    "Creating folder ({0})".format(my_version))
                shutil.copytree(
                    Context().environment.store_source.strip() +
                    Configuration().version_presta,
                    Context().environment.store_source.strip() + my_version)

                Context().logger.info("Folder was created")
            except WindowsError:
                Context().logger.error("Issue to duplicate the folder")
        else:
            try:
                Context().logger.info(
                    "Create since git the folder {0})".format(my_version))
                if var_test.get('git_repo') == "":
                    grepo = Configuration().git_repo
                else:
                    grepo = var_test.get('git_repo')
                os.system("git clone --recursive " + grepo + " " +
                          Context().environment.store_source + my_version)
                Context().logger.info("Folder was cloned since git")
            except WindowsError:
                Context().logger.error(
                    "Issue to clone the folder since git {0}".format())

        Context().launch_browser2(clean_session=True)
        my_url = "http://str(j)str(i)/install-dev/index.php"
        storename = "/"
        if Configuration().storename != None:
            storename = Configuration().storename + storename
        if Configuration().vm == None:
            url = my_url.replace('str(i)',
                                 storename).replace('str(j)', 'localhost/')
        else:
            url = my_url.replace('str(i)',
                                 storename).replace('str(j)',
                                                    Configuration().vm + '/')

        Context().goto_url(url)
        lang = ui.def_object(self._objects['langue'], var_test.get("langue"))
        ui.click(self._objects['langue_list'])
        ui.click(lang)
        ui.click(self._objects['next'])

        ui.click(self._objects['valid_license'])
        ui.click(self._objects['next'])

        time.sleep(3)
        ui.click(self._objects['next'])

        ui.set_text(self._objects['name'], my_version, True)
        ui.set_text(self._objects['firstname'], var_test.get("firstname"),
                    True)
        ui.set_text(self._objects['lastname'], var_test.get("lastname"), True)
        ui.set_text(self._objects['email'], var_test.get("email"), True)
        ui.set_text(self._objects['password'], var_test.get("password"), True)
        ui.set_text(self._objects['password2'], var_test.get("password"), True)
        ui.click(self._objects['next'])

        ui.set_text(self._objects['dbServer'], var_test.get("dbServer"))

        if var_test.get("dbName") == "":
            ui.set_text(self._objects['dbName'], my_version, True)
        else:
            ui.set_text(self._objects['dbName'], var_test.get("dbName"))
        ui.set_text(self._objects['dbLogin'], var_test.get("dbLogin"))
        ui.set_text(self._objects['dbPassword'], var_test.get("dbPassword"))

        if var_test.get("dbprefix") == "":
            ui.set_text(self._objects['dbprefix'],
                        ((my_version.replace(".", "")).replace("_", "") + "_"),
                        True)
        else:
            ui.set_text(self._objects['dbprefix'], var_test.get("dbprefix"))
        ui.click(self._objects['btn_test_db'])

        ui.wait_loader("//p[@id='dbResultCheck' and @class='waitBlock']", 30,
                       1)

        db_check = ui.get_class(self._objects['check_db'])
        if db_check == "errorBlock":
            try:
                ui.click(self._objects['btn_create_db'])
                Context().logger.info("DB doesn't exist, try to generate it")
                try:
                    ui.wait_until(
                        "//p[@id='dbResultCheck' and @class='okBlock']", 60, 1)
                    Context().logger.info("DB was generated without issue")
                    ui.click(self._objects['btn_test_db'])
                    ui.wait_loader(
                        "//p[@id='dbResultCheck' and @class='waitBlock']", 60,
                        1)
                    ui.find_element(
                        "xpath",
                        "//p[@id='dbResultCheck' and @class='okBlock']")
                except:
                    try:
                        ui.wait_until(
                            "//p[@id='dbResultCheck' and @class='errorBlock']",
                            60, 1)
                        Context().logger.error("Issue to create the DB")
                    except:
                        Context().logger.error(
                            "Issue to have the status of the creation of the DB"
                        )
            except:
                Context().logger.info(
                    "DB with this prefix already exist, try with another prefix"
                )
                ui.set_text(
                    self._objects['dbprefix'],
                    datetime.datetime.now().strftime("%Y%m%d%H%M%S") + "_",
                    True)
                ui.click(self._objects['btn_test_db'])
                ui.wait_loader(
                    "//p[@id='dbResultCheck' and @class='waitBlock']", 30, 1)
                db_check = ui.get_class(self._objects['check_db'])
                if db_check == "errorBlock":
                    ui.click(self._objects['btn_create_db'])
                    Context().logger.info(
                        "DB doesn't exist, try to generate it")
                    try:
                        ui.wait_until(
                            "//p[@id='dbResultCheck' and @class='okBlock']",
                            60, 1)
                        Context().logger.info("DB was generated without issue")
                        ui.click(self._objects['btn_test_db'])
                        ui.wait_loader(
                            "//p[@id='dbResultCheck' and @class='waitBlock']",
                            60, 1)
                        ui.find_element(
                            "xpath",
                            "//p[@id='dbResultCheck' and @class='okBlock']")
                    except:
                        try:
                            ui.wait_until(
                                "//p[@id='dbResultCheck' and @class='errorBlock']",
                                60, 1)
                            Context().logger.error("Issue to create the DB")
                        except:
                            Context().logger.error(
                                "Issue to have the status of the creation of the DB"
                            )
                elif db_check == "okBlock":
                    Context().logger.info("DB is ok")
                else:
                    Context().logger.error(
                        "Issue to have the status of the DB")
        elif db_check == "okBlock":
            Context().logger.info("DB is ok")
        else:
            Context().logger.error("Issue to have the status of the DB")
        ui.click(self._objects['next'])

        ui.wait_until("//div[@class='progress']", 120, 5)
        ui.wait_loader("//ul[@id='stepList_1']//li[6][not(@class)]", 600, 10)
        try:
            ui.find_element("xpath",
                            "//ul[@id='stepList_1']//li[6][@class='ok']")
            Context().logger.info("Installation of the account is completed")
            try:
                Context().browser.close()
                Context().launch_browser2(clean_session=True)
                storename = "/"
                if Configuration().storename != None:
                    storename = Configuration().storename + storename
                if Configuration().vm == None:
                    url = Context().environment.url.replace(
                        'str(i)', storename).replace('str(j)', 'localhost/')
                else:
                    url = Context().environment.url.replace(
                        'str(i)', storename).replace('str(j)',
                                                     Configuration().vm + '/')
                Context().goto_url(url)
                loginAdminPageScreen().connect(var_test.get("email"),
                                               var_test.get("password"))
                time.sleep(3)
                if (ui.is_visible(self._objects['close_welcome_popup'])):
                    ui.click(self._objects['close_welcome_popup'])
                loginAdminPageScreen().disconnect()
                install_ok = True
            except:
                Context().logger.error(
                    "Issue to close the current browser and open a new one to the new store."
                )
        except:
            ui.take_screenshot("Exception.png")
            Context().logger.error(
                "Issue to finalize the creation of the account")

        return install_ok
コード例 #8
0
    def reinstall_shop(self, var_test):
        reinstall_ok = False
        Context().launch_browser2(clean_session=True)
        my_url = "http://str(j)str(i)/install-dev/index.php"
        storename = "/"
        if Configuration().storename != None:
            storename = Configuration().storename + storename
        if Configuration().vm == None:
            url = my_url.replace('str(i)',
                                 storename).replace('str(j)', 'localhost/')
        else:
            url = my_url.replace('str(i)',
                                 storename).replace('str(j)',
                                                    Configuration().vm + '/')

        Context().goto_url(url)
        time.sleep(2)
        lang = ui.def_object(self._objects['langue'], var_test.get("langue"))
        ui.click(lang)
        ui.click(lang)
        time.sleep(5)
        ui.click(self._objects['next'])

        ui.click(self._objects['valid_license'])
        ui.click(self._objects['next'])

        time.sleep(3)
        ui.click(self._objects['next'])

        ui.set_text(self._objects['name'],
                    Configuration().version_presta, True)
        ui.set_text(self._objects['firstname'], var_test.get("firstname"),
                    True)
        ui.set_text(self._objects['lastname'], var_test.get("lastname"), True)
        ui.set_text(self._objects['email'], var_test.get("email"), True)
        ui.set_text(self._objects['password'], var_test.get("password"), True)
        ui.set_text(self._objects['password2'], var_test.get("password"), True)
        ui.click(self._objects['next'])

        ui.set_text(self._objects['dbServer'], var_test.get("dbServer"))
        if var_test.get("dbName") == "":
            ui.set_text(self._objects['dbName'],
                        Configuration().storename, True)
        else:
            ui.set_text(self._objects['dbName'], var_test.get("dbName"))
        ui.set_text(self._objects['dbLogin'], var_test.get("dbLogin"))
        ui.set_text(self._objects['dbPassword'], var_test.get("dbPassword"))
        ui.click(self._objects['btn_test_db'])

        ui.wait_loader("//p[@id='dbResultCheck' and @class='waitBlock']", 30,
                       1)

        db_check = ui.get_class(self._objects['check_db'])
        if db_check == "errorBlock":
            try:
                ui.click(self._objects['btn_create_db'])
                Context().logger.info("DB doesn't exist, try to generate it")
                try:
                    ui.wait_until(
                        "//p[@id='dbResultCheck' and @class='okBlock']", 60, 1)
                    Context().logger.info("DB was generated without issue")
                    ui.click(self._objects['btn_test_db'])
                    ui.wait_loader(
                        "//p[@id='dbResultCheck' and @class='waitBlock']", 60,
                        1)
                    ui.find_element(
                        "xpath",
                        "//p[@id='dbResultCheck' and @class='okBlock']")
                except:
                    try:
                        ui.wait_until(
                            "//p[@id='dbResultCheck' and @class='errorBlock']",
                            60, 1)
                        Context().logger.error("Issue to create the DB")
                    except:
                        Context().logger.error(
                            "Issue to have the status of the creation of the DB"
                        )
            except:
                Context().logger.info(
                    "DB with this prefix already exist, try with another prefix"
                )
                ui.set_text(
                    self._objects['dbprefix'],
                    datetime.datetime.now().strftime("%Y%m%d%H%M%S") + "_",
                    True)
                ui.click(self._objects['btn_test_db'])
                ui.wait_loader(
                    "//p[@id='dbResultCheck' and @class='waitBlock']", 30, 1)
                db_check = ui.get_class(self._objects['check_db'])
                if db_check == "errorBlock":
                    ui.click(self._objects['btn_create_db'])
                    Context().logger.info(
                        "DB doesn't exist, try to generate it")
                    try:
                        ui.wait_until(
                            "//p[@id='dbResultCheck' and @class='okBlock']",
                            60, 1)
                        Context().logger.info("DB was generated without issue")
                        ui.click(self._objects['btn_test_db'])
                        ui.wait_loader(
                            "//p[@id='dbResultCheck' and @class='waitBlock']",
                            60, 1)
                        ui.find_element(
                            "xpath",
                            "//p[@id='dbResultCheck' and @class='okBlock']")
                    except:
                        try:
                            ui.wait_until(
                                "//p[@id='dbResultCheck' and @class='errorBlock']",
                                60, 1)
                            Context().logger.error("Issue to create the DB")
                        except:
                            Context().logger.error(
                                "Issue to have the status of the creation of the DB"
                            )
                elif db_check == "okBlock":
                    Context().logger.info("DB is ok")
                else:
                    Context().logger.error(
                        "Issue to have the status of the DB")
        elif db_check == "okBlock":
            Context().logger.info("DB is ok")
        else:
            Context().logger.error("Issue to have the status of the DB")
        ui.click(self._objects['next'])

        ui.wait_until("//div[@class='progress']", 120, 5)
        ui.wait_loader("//ul[@id='stepList_1']//li[6][not(@class)]", 600, 10)
        try:
            ui.find_element("xpath",
                            "//ul[@id='stepList_1']//li[6][@class='ok']")
            Context().logger.info("Installation of the account is completed")
            try:
                Context().browser.close()
                Context().launch_browser2(clean_session=True)
                if Configuration().vm == None:
                    url = Context().environment.url.replace(
                        'str(i)', storename).replace('str(j)', 'localhost/')
                else:
                    url = Context().environment.url.replace(
                        'str(i)', storename).replace('str(j)',
                                                     Configuration().vm + '/')

                Context().goto_url(url)
                loginAdminPageScreen().connect(var_test.get("email"),
                                               var_test.get("password"))
                time.sleep(3)
                if (ui.is_visible(self._objects['close_welcome_popup'])):
                    ui.click(self._objects['close_welcome_popup'])
                loginAdminPageScreen().disconnect()
                reinstall_ok = True
            except:
                Context().logger.error(
                    "Issue to close the current browser and open a new one to the new store."
                )
        except:
            ui.take_screenshot("Exception.png")
            Context().logger.error(
                "Issue to finalize the creation of the account")

        return reinstall_ok
コード例 #9
0
    def add_employees(self, var_test):
        if ui.get_text(self._objects['employees_table_number']) == "1":
            max_id = ui.get_text(
                self._objects['employees_table_check']).split(" ")[0]
        else:
            ui.click(self._objects['employees_table_id_desc'])
            time.sleep(3)
            max_id = ui.get_text(
                self._objects['employees_table_check']).split(" ")[0]
        ui.click(self._objects['add_employees'])
        ui.wait_until(self._objects['add_employee_firstname'][1], 60, 1,
                      self._objects['add_employee_firstname'][0])
        ui.set_text(self._objects['add_employee_firstname'],
                    var_test.get("firstname"))
        ui.set_text(self._objects['add_employee_lastname'],
                    var_test.get("lastname"))

        false_random = int(max_id) + 1
        my_email = (Context().browser.name + str(false_random) +
                    var_test.get("email")).replace(" ", "")
        ui.set_text(self._objects['add_employee_email'], my_email)
        ui.set_text(self._objects['add_employee_password'],
                    var_test.get("password"))
        if var_test.get("prestanl") == "yes":
            ui.click(self._objects['add_employee_nl_on'])
        if var_test.get("prestanl") == "no":
            ui.click(self._objects['add_employee_nl_off'])
        if var_test.get("active") == "yes":
            ui.click(self._objects['add_employee_active_on'])
        if var_test.get("active") == "no":
            ui.click(self._objects['add_employee_active_off'])
        my_profile = ("xpath", "//*[@id = 'id_profile']/option[text()='" +
                      var_test.get("profile") + "']")
        ui.click(my_profile)
        ui.click(self._objects['add_employee_save'])
        time.sleep(3)
        my_employee = {}
        my_employee.update({'old_max_id': max_id})
        my_employee.update({'my_email': my_email})
        my_employee.update({'firstname': var_test.get("firstname")})
        my_employee.update({'lastname': var_test.get("lastname")})
        my_employee.update({'profil': var_test.get("profile")})
        my_employee.update({'active': var_test.get("active")})
        return my_employee