Exemplo n.º 1
0
 def AddProduct(self,username,password,position,reference,code,price,name,short,description):
     # Open Add product page
     AdminBase.navigate_to_admin(self,username,password)
     AdminBase.add_product_navigator(self)
     # Add first
     self.driver.find_element(*ProductsModule.category).click()
     self.driver.find_element(*ProductsModule.position).clear()
     self.driver.find_element(*ProductsModule.position).send_keys(position)
     self.driver.find_element(*ProductsModule.our_selection).click()
     self.driver.find_element(*ProductsModule.new).click()
     self.driver.find_element(*ProductsModule.special).click()
     self.driver.find_element(*ProductsModule.reseller).click()
     self.driver.find_element(*ProductsModule.recommended).click()
     self.driver.find_element(*ProductsModule.best).click()
     self.driver.find_element(*ProductsModule.state_online).click()
     self.driver.find_element(*ProductsModule.reference).send_keys(reference)
     self.driver.find_element(*ProductsModule.code).send_keys(code)
     self.driver.find_element(*ProductsModule.price).send_keys(price)
     self.driver.find_elements(*ProductsModule.colors)[1].click()
     # add second tab
     self.driver.find_element(*ProductsModule.english_tab).click()
     self.driver.find_element(*ProductsModule.product_name).send_keys(name)
     self.driver.find_element(*ProductsModule.short_description).send_keys(short)
     self.driver.find_element(*ProductsModule.description).send_keys(description)
     # submit
     self.driver.find_element(*ProductsModule.save_button).click()
     return self.driver.find_element(*ProductsModule.confirm_msg).text
Exemplo n.º 2
0
    def delete_category(self, username, password,categoryname):
        # Open category page
        AdminBase.navigate_to_admin(self,username, password)
        AdminBase.edit_category_navigator(self)

        # delete category
        id = ''
        # get list of categories names
        for i in self.driver.find_elements_by_css_selector('tr[class="classe1"] td:nth-child(4) a'):
            if i.text == categoryname:
                ref = i.get_attribute('href')
                category_id=ref.split('=')
                id = category_id[2]
                self.driver.find_element_by_css_selector('a[href="http://10.1.22.67/Jamaica/administrer/categories.php?mode=suppr&id={}"]'.format(id)).click()
                self.driver.find_element(*CategoryPage.confirm_delete).click()
                return self.driver.find_element(*CategoryPage.alert).text
            else:
                continue
Exemplo n.º 3
0
    def AddCoupon(self,username,password,code_name,start,end,sale):
        # Open coupon codes page
        AdminBase.navigate_to_admin(self,username,password)
        AdminBase.add_coupon_navigator(self)
        # Add coupon
        self.driver.find_element(*AddPromotionCodePage.add_coupon_button).click()
        self.driver.find_element(*AddPromotionCodePage.promotion_code).send_keys(code_name)
        self.driver.find_element(*AddPromotionCodePage.start_date).clear()
        self.driver.find_element(*AddPromotionCodePage.start_date).send_keys(start)
        self.driver.find_element(*AddPromotionCodePage.end_date).clear()
        self.driver.find_element(*AddPromotionCodePage.end_date).send_keys(end)
        self.driver.find_element(*AddPromotionCodePage.discount).click()
        self.driver.find_element(*AddPromotionCodePage.discount).send_keys(int(sale))
        self.driver.find_element(*AddPromotionCodePage.status_active).click()

        # submit
        self.driver.find_element(*AddPromotionCodePage.submitbutton).click()
        return self.driver.find_element(*AddPromotionCodePage.alert).text
Exemplo n.º 4
0
    def uppload_image(self,username,password,name):
        # Add product details
        AdminBase.navigate_to_admin(self,username,password)
        AdminBase.edit_product_navigator(self)

        modify_product = self.driver.find_element_by_css_selector('a[title="Delete {}"]+a[title="Modify"]'.format(name)).get_attribute('href')
        product_id=modify_product.split('&')
        idmsg = product_id[1].split('=')
        id = idmsg[1]
        self.driver.find_element_by_css_selector('a[title="Delete {}"]+a[title="Modify"]'.format(name)).click()
        #edit Third tab - Jihad
        self.driver.find_element(*ProductsModule.file_associated_tab).click()
        self.driver.find_element(*ProductsModule.add_image).click()
        self.driver.find_element(*ProductsModule.chose_file_button).click()
        os.system("..\\utilities\\jihad.exe")
        time.sleep(5)
        self.driver.switch_to_window(self.driver.window_handles[0])
        self.driver.find_element(*ProductsModule.save_button).click()
Exemplo n.º 5
0
 def edit_user(self,username,password,email):
     # Open edit user page
     AdminBase.navigate_to_admin(self,username,password)
     AdminBase.view_users(self)
     # click on edit for specific user
     for i in self.driver.find_elements(*ManageUserPage.users_mail):
         if i.text == email:
             ref = i.get_attribute('href')
             user_id=ref.split('=')
             id = user_id[1]
             self.driver.find_element_by_css_selector('a[href="http://10.1.22.67/Jamaica/administrer/utilisateurs.php?mode=modif&id_utilisateur={}&start=0"]'.format(id)).click()
             # change permission
             for x in self.driver.find_elements(*ManageUserPage.user_permission):
                 if x.text != '[Jamaica] Client':
                     x.click()
             self.driver.find_element(*ManageUserPage.save_button).click()
             return self.driver.find_element(*ManageUserPage.alert).text
         else:
             continue
Exemplo n.º 6
0
    def add_flash_sale_to_product(self,username,password,price,start,end,name):
        # Open edit product page
        AdminBase.navigate_to_admin(self,username,password)
        AdminBase.edit_product_navigator(self)
        self.driver.find_element_by_css_selector('a[title="Delete {}"]+a[title="Modify"]'.format(name)).click()

        # add flash sale
        self.driver.find_element(*FlashSalePage.flash_sale_price).clear()
        self.driver.find_element(*FlashSalePage.flash_sale_price).send_keys(int(price))
        self.driver.find_element(*FlashSalePage.start_date).click()
        self.driver.find_element(*FlashSalePage.start_date).clear()
        self.driver.find_element(*FlashSalePage.start_date).send_keys(start)
        self.driver.find_element(*FlashSalePage.end_date).click()
        self.driver.find_element(*FlashSalePage.end_date).clear()
        self.driver.find_element(*FlashSalePage.end_date).send_keys(end)

        # submit
        self.driver.find_element(*FlashSalePage.save_changes_button).click()
        return self.driver.find_element(*FlashSalePage.alert).text
Exemplo n.º 7
0
    def verify_flash_sale_price(self,username,password,productname):
        # user can call that function from different views (product, admin, landing page)
        # Open edit product page
        AdminBase.navigate_to_admin(self,username,password)
        AdminBase.edit_product_navigator(self)
        self.driver.find_element_by_css_selector('a[title="Delete {}"]+a[title="Modify"]'.format(productname)).click()

        # view online
        self.driver.find_element(*FlashSalePage.view_online).click()
        window_before = self.driver.window_handles[0]
        window_after = self.driver.window_handles[1]
        self.driver.switch_to.window(window_after)
        new = self.driver.find_element(*FlashSalePage.price).text
        self.driver.close()
        self.driver.switch_to_window(window_before)

        # extract product new price
        whole_text = new.split(',')
        exact_price = whole_text[0]
        return int(exact_price)
Exemplo n.º 8
0
    def verify_remaining_time_to_end_sale(self,username,password,productname,end_time):
       # user can call that function from different views (product, admin, landing page)
        # Open edit product page
        AdminBase.navigate_to_admin(self,username,password)
        AdminBase.edit_product_navigator(self)
        self.driver.find_element_by_css_selector('a[title="Delete {}"]+a[title="Modify"]'.format(productname)).click()

        # view online
        self.driver.find_element(*FlashSalePage.view_online).click()
        window_before = self.driver.window_handles[0]
        window_after = self.driver.window_handles[1]
        self.driver.switch_to.window(window_after)
        alert1 = self.driver.find_element(*FlashSalePage.remaining_time).text
        self.driver.close()
        self.driver.switch_to_window(window_before)

        time_list = re.findall(r'(?:\d)?\d+', alert1)
        now = datetime.datetime.now()
        remaining_time = parser.parse(end_time) - now
        if remaining_time.days == time_list[0]:
            return True
        else:
            return False
Exemplo n.º 9
0
    def add_category(self,username,password,categoryname, parent):
        # Open category page
        AdminBase.navigate_to_admin(self,username, password)
        AdminBase.add_category_navigator(self)
        if parent == "":
            #  Add category
            self.driver.find_element(*CategoryPage.root_category).click()
        else:
            # Add sub category
            for i in self.driver.find_elements(*CategoryPage.parents):
                if i.text == parent:
                    i.click()
        self.driver.find_element(*CategoryPage.view_on_home).click()
        self.driver.find_element(*CategoryPage.state_online).click()
        self.driver.find_element(*CategoryPage.name).send_keys(categoryname)

        # submit
        self.driver.find_element(*CategoryPage.add_category_button).click()

        # Open edit category page
        AdminBase.edit_category_navigator(self)
        self.driver.find_element_by_link_text(categoryname).click()

        # view online
        self.driver.find_element(*CategoryPage.view_online).click()

        window_before = self.driver.window_handles[0]
        window_after = self.driver.window_handles[1]
        self.driver.switch_to.window(window_after)
        category_page_title = self.driver.find_element(*CategoryPage.page_title).text
        self.driver.close()
        self.driver.switch_to_window(window_before)
        # Check category name
        if category_page_title == categoryname:
            return True
        else:
            return False
Exemplo n.º 10
0
    def edit_product(self,username,password,name,tab1,tab2):
        # Add product details
        AdminBase.navigate_to_admin(self,username,password)
        AdminBase.edit_product_navigator(self)

        modify_product = self.driver.find_element_by_css_selector('a[title="Delete {}"]+a[title="Modify"]'.format(name)).get_attribute('href')
        product_id=modify_product.split('&')
        idmsg = product_id[1].split('=')
        id = idmsg[1]
        self.driver.find_element_by_css_selector('a[title="Delete {}"]+a[title="Modify"]'.format(name)).click()
        self.driver.find_element(*ProductsModule.english_tab).click()
        self.driver.find_element_by_css_selector('a[href="http://10.1.22.67/Jamaica/administrer/produits.php?mode=modif_tab&id={}&tab_lang=en"]'.format(id)).click()
        window_before = self.driver.window_handles[0]
        window_after = self.driver.window_handles[1]
        self.driver.switch_to.window(window_after)
        self.driver.find_element(*ProductsModule.content_tab1).clear()
        self.driver.find_element(*ProductsModule.content_tab1).send_keys(tab1)
        self.driver.find_element(*ProductsModule.content_tab2).clear()
        self.driver.find_element(*ProductsModule.content_tab2).send_keys(tab2)
        self.driver.find_element(*ProductsModule.save_content).click()
        alert= self.driver.find_element(*ProductsModule.confirm_tab2).text
        self.driver.close()
        self.driver.switch_to_window(window_before)
        return alert
Exemplo n.º 11
0
 def delete_product(self,username,password,name):
     AdminBase.navigate_to_admin(self,username,password)
     AdminBase.edit_product_navigator(self)
     self.driver.find_element_by_css_selector('a[title="Delete {}"]'.format(name)).click()
     self.driver.find_element(*ProductsModule.confirm_delete).click()