Exemple #1
0
class CartTests(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)

    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.cp = CartPage(self.driver)
        self.lp = LoginPage(self.driver)
        self.ts = TestStatus(self.driver)
        self.nav = NavigationPage(self.driver)
        self.sd = SeleniumDriver(self.driver)

    @pytest.mark.run(order=1)
    def test_fewProductsCartSuccessful(self):
        self.log.info("Get few products to cart successful")
        result = self.cp.getFewProductsToCartSuccessful(quantity=2)
        assert result == True

    @pytest.mark.run(order=2)
    def test_priceOfProductsSuccessful(self):
        self.log.info("Price of products in cart page successful")
        self.nav.clearCartAndGoToMainPage()
        result = self.cp.priceOfProductsInBasket(quantity=2)
        assert result == True

    @pytest.mark.run(order=3)
    def test_deleteFromCartSuccessful(self):
        self.log.info("Delete from cart successful")
        self.nav.clearCartAndGoToMainPage()
        result = self.cp.deleteFromCart()
        assert result == True

    @pytest.mark.run(order=4)
    def test_changeQuantitySuccessful(self):
        self.log.info("Change quantity of products in cart successful")
        self.nav.clearCartAndGoToMainPage()
        result = self.cp.changeQuantity()
        assert result == True
        self.ts.markFinal(
            "test_changeQuantitySuccessful", result,
            "Changed quantity of products in cart Successful "
            "verification SUCCESSED")
Exemple #2
0
class SearchTests(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)

    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.sp = productSearch(self.driver)
        self.ts = TestStatus(self.driver)
        self.nav = NavigationPage(self.driver)

    @pytest.mark.run(order=1)
    @data(*getCSVData("textSearchSuccessful.csv"))
    @unpack
    def test_searchByNumSuccessful(self, text, numindatabase):
        self.log.info("Test successful text search on the home page")
        self.nav.backToHomePage()
        self.sp.searchProductsByText(text)
        result = self.sp.searchSuccesfulByNum(numindatabase)
        assert result == True

    @pytest.mark.run(order=2)
    @data(*getCSVData("textSearchByNum.csv"))
    @unpack
    def test_searchByTextSuccessful(self, text):
        self.log.info("Test successful text search on the home page")
        self.nav.backToHomePage()
        self.sp.searchProductsByText(text)
        result = self.sp.searchSuccessfulByText(text)
        assert result == True


    @pytest.mark.run(order=3)
    @data(*getCSVData("textSearchFailed.csv"))
    @unpack
    def test_searchByTextFailed(self,text):
        self.log.info("Test failed text search on the home page")
        self.nav.backToHomePage()
        self.sp.searchProductsByText(text)
        result = self.sp.searchFailed()
        assert result == True
        self.ts.markFinal("test_searchByTextFailed", result, "Text search on the home page verification SUCCESSED")
Exemple #3
0
class FiltersPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.nav = NavigationPage(driver)

    #Loctors
    _clothes_page = "//a[@href='http://localhost/prestashop/3-clothes']"  #by xpath
    _men_page = '//ul[@class="category-sub-menu"]//a[contains(text(),"Men")]'  #byXpath
    _man_collapse_menu = '//div[@id="left-column"]//ul[@class="category-sub-menu"]/li[1]/div[1]]'  #byXpath
    _woman_page = '//ul[@class="category-sub-menu"]//a[@href="http://localhost/prestashop/5-women"]'  #byXpath
    _woman_collapse_menu = '//div[@id="left-column"]//ul[@class="category-sub-menu"]/li[2]/div[1]'  #byXpath
    _woman_collapse_menu_bluzki = '//ul[@class="category-sub-menu"]/li[2]//ul[@class="category-sub-menu"]//a[contains(text(),"Bluzki")]'
    # clothes
    #sizes:
    _size_S = '//div[@id="search_filters"]/section[2]/ul/li[1]//span[@class="custom-checkbox"]'
    _size_M = '//div[@id="search_filters"]/section[2]/ul/li[2]//span[@class="custom-checkbox"]'
    _size_L = '//div[@id="search_filters"]/section[2]/ul/li[3]//span[@class="custom-checkbox"]'
    _size_XL = '//div[@id="search_filters"]/section[2]/ul/li[4]//span[@class="custom-checkbox"]'
    #colors:
    _white_color = '//div[@id="search_filters"]/section[3]/ul/li[1]//span[@class="custom-checkbox"]/input'
    _black_color = '//div[@id="search_filters"]/section[3]/ul/li[2]//span[@class="custom-checkbox"]/input'
    #prices:
    _price_cat1 = '//div[@id="search_filters"]/section[4]/ul/li[1]//span[@class="custom-checkbox"]'
    _price_cat2 = '//div[@id="search_filters"]/section[4]/ul/li[2]//span[@class="custom-checkbox"]'
    _price_cat3 = '//div[@id="search_filters"]/section[4]/ul/li[3]//span[@class="custom-checkbox"]'
    _price_cat4 = '//div[@id="search_filters"]/section[4]/ul/li[4]//span[@class="custom-checkbox"]'

    def goToMenPageSuccessful(self):
        self.nav.goToClothesPage()
        self.elementClick(locator=self._men_page, locatorType='xpath')
        self.waitForElement(
            locator=
            '//div[@class="block-category card card-block hidden-sm-down"]/h1[contains(text(), "Men")]',
            locatorType='xpath')
        result = self.isElementPresent(
            locator=
            '//div[@class="block-category card card-block hidden-sm-down"]/h1[contains(text(), "Men")]',
            locatorType='xpath')
        return result

    def clothesWomenBluzkiPage(self):
        self.waitForElement(
            locator=
            "//div[@id='js-product-list']/div[@class='products row']/article[1]"
        )
        products = self.driver.find_elements(
            By.XPATH,
            "//div[@id='js-product-list']/div[@class='products row']//h1[@class='h3 product-title']/a"
        )
        for el in products:
            product = el.text
            if 'Bluzka' not in product:
                return False
        return True

    def clothesPagehoverOverMenu(self):
        self.nav.backToHomePage()
        element = self.driver.find_element(By.XPATH, self._clothes_page)
        actions = ActionChains(self.driver)
        actions.move_to_element(element).perform()
        self.waitForElement(locator="//ul[@id='top-menu']/li[1]/div",
                            locatorType="xpath")
        self.elementClick(
            locator=
            "//ul[@id='top-menu']/li[1]/div/ul/li[2]//a[contains(text(),'Bluzki')]",
            locatorType="xpath")

    def collapseMenuWomenBlouse(self):
        self.nav.goToClothesPage()
        self.waitForElement(locator=self._woman_collapse_menu,
                            locatorType="xpath")
        self.elementClick(locator=self._woman_collapse_menu,
                          locatorType="xpath")
        self.waitForElement(locator=self._woman_collapse_menu_bluzki,
                            locatorType='xpath')
        self.elementClick(locator=self._woman_collapse_menu_bluzki,
                          locatorType='xpath')

    def multipleFiltersClick(self):
        # Clicks on the color and size clothes
        self.nav.goToClothesPage()
        self.driver.execute_script("window.scrollBy(0, -300);")
        self.waitForElement(locator='search_filters')
        self.elementClick(locator=self._size_M, locatorType='xpath')
        time.sleep(2)
        self.elementClick(locator=self._black_color, locatorType='xpath')
        time.sleep(2)

    def multipleFiltersSuccessful(self):
        # Checks if selected products are the same as products in database
        products = []
        text_list = []
        product_list = self.driver.find_elements(
            By.XPATH,
            "//div[@class='products row']/article//h1[@class='h3 product-title']/a"
        )
        for product in product_list:
            hr = product.text
            text_list.append(hr.lower())
        file = open("product_list_black_m.txt", "r", encoding="utf-8")
        product_list_database = file.readlines()
        for line in product_list_database:
            el = line.rstrip()
            products.append(el.lower())
        for line in products:
            if line not in text_list:
                return False
        return True
Exemple #4
0
 def __init__(self, driver):
     super().__init__(driver)
     self.driver = driver
     self.nav = NavigationPage(driver)
Exemple #5
0
class ProductPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.nav = NavigationPage(driver)

    # Locators
    _product_title = "h1"  #byclass
    _product_description = "product-description-short-30"  #byId
    _size_S = '//div[@id="search_filters"]/section[2]/ul/li[1]//span[@class="custom-checkbox"]'
    _zoom_in_img = "material-icons zoom-in"  #byClass
    _enlarge_img = "//div[@role='document']//figure/img"  #byxpath width = 800
    _img = "//div[@class='images-container']/div[1]/img"  #byxpath
    _panda_tshirt = "//div[@id='js-product-list']/div[@class='products row']//a[contains(text(),'T-shirt Panda')]"  # byXpath
    _product_availability = "product-availability"  #byID
    _add_to_cart = "//form[@id='add-to-cart-or-refresh']//button[@type='submit']"

    def goToProductPage(self):
        self.nav.goToClothesPage()
        self.waitForElement(locator=self._panda_tshirt, locatorType="xpath")
        self.elementClick(locator=self._panda_tshirt, locatorType="xpath")
        self.waitForElement(locator=self._product_title, locatorType="class")

    def productTitle(self, title):
        self.goToProductPage()
        product = self.getElement(locator=self._product_title,
                                  locatorType="class")
        productTitle = product.text.lower()
        if title == productTitle:
            result = True
        else:
            result = False
        return result

    def productDescription(self, description):
        self.goToProductPage()
        productDescription = self.getElement(
            locator=self._product_description).text
        if description == productDescription:
            result = True
        else:
            result = False
        return result

    def imgDisplayed(self):
        self.goToProductPage()
        result = self.isElementDisplayed(locator=self._img,
                                         locatorType="xpath")
        return result

    def imgEnlarge(self):
        self.goToProductPage()
        self.elementClick(locator=self._zoom_in_img, locatorType="class")
        self.waitForElement(locator=self._enlarge_img, locatorType="xpath")
        img = self.getElement(locator=self._enlarge_img, locatorType="xpath")
        width = img.get_attribute("width")
        if width == "800":
            result = True
        else:
            result = False
        return result

    def sizeNotAvailable(self):
        self.goToProductPage()
        self.elementClick(locator=self._size_S, locatorType="xpath")
        self.waitForElement(locator=self._product_availability)
        availability = self.isElementDisplayed(
            locator=self._product_availability)
        addToCart = self.getElement(locator=self._add_to_cart,
                                    locatorType="xpath")
        addToCartStatus = addToCart.is_enabled()
        if (addToCartStatus == False) and (availability == True):
            result = True
        else:
            result = False
        return result
Exemple #6
0
 def objectSetup(self, oneTimeSetUp):
     self.dp = DiscountsPage(self.driver)
     self.lp = LoginPage(self.driver)
     self.ts = TestStatus(self.driver)
     self.nav = NavigationPage(self.driver)
Exemple #7
0
 def objectSetup(self, oneTimeSetUp):
     self.fp = FiltersPage(self.driver)
     self.ts = TestStatus(self.driver)
     self.nav = NavigationPage(self.driver)
 def __init__(self, driver):
     super().__init__(driver)
     self.driver = driver
     self.nav = NavigationPage(self.driver)
     self.lp = LoginPage(self.driver)
     self.cp = CartPage(self.driver)
Exemple #9
0
class CartPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.nav = NavigationPage(self.driver)
        self.lp = LoginPage(self.driver)

    #Loctors
    _cart = "_desktop_cart" #byID
    _add_to_cart = "//form[@id='add-to-cart-or-refresh']//button[@type='submit']"
    _panda_tshirt = "//div[@id='js-product-list']/div[@class='products row']//a[contains(text(),'T-shirt Panda')]"  # byXpath
    _bluzka_Fiona = "//div[@class='products row']//a[contains(text(),'Bluzka Fiona')]"
    _select_size = "group[1]" #byName
    _size_M = "//select[@name='group[1]']/option[@title='M']"
    _color = "group[2]" #byName
    _quantity = "quantity_wanted" #byID
    _go_to_fulfill_the_order_button = "//div[@class='modal-content']//a" #byxpath
    _continue_shopping_button = "//button[contains(text(),'Kontynuuj zakupy')]" #byxpath
    _num_of_products_in_cart = "//div[@id='cart-subtotal-products']/span[1]"
    _first_product_trashcan = "//ul[@class='cart-items']//a[@href='http://localhost/prestashop/koszyk?delete=1&id_product=30&id_product_attribute=150&token=41accb438c23197911beb3a379f403de']/i[.='delete']"
    _products_in_cart = "//div[@class='card cart-container']//ul[@class='cart-items']/li"
    _touchspin_down = "//div[@class='card cart-container']//li[1]/div[@class='product-line-grid']//span[@class='input-group-btn-vertical']/button[2]"

    def getProductToCartPanda(self, quantity):
        self.nav.goToClothesPage()
        self.waitForElement(locator="//div[@id='js-product-list']/div[@class='products row']/article[1]",
                            locatorType='xpath')
        self.elementClick(locator=self._panda_tshirt, locatorType='xpath')
        self.waitForElement(locator=self._size_M, locatorType="xpath")
        self.elementClick(locator=self._select_size, locatorType="name")
        self.elementClick(locator=self._size_M, locatorType="xpath")
        self.elementClick(locator=self._color, locatorType="name")
        self.clearField(locator=self._quantity)
        self.sendKeys(quantity, locator=self._quantity)
        time.sleep(2)
        self.elementClick(locator=self._add_to_cart, locatorType="xpath")
        self.waitForElement(locator="cart-content", locatorType="class")

    def getProductToCartFiona(self,quantity):
        self.nav.goToClothesPage()
        self.waitForElement(locator=self._bluzka_Fiona, locatorType='xpath')
        self.elementClick(locator=self._bluzka_Fiona, locatorType='xpath')
        self.waitForElement(locator=self._add_to_cart, locatorType="xpath")
        self.elementClick(locator=self._select_size, locatorType="name")
        self.elementClick(locator=self._size_M, locatorType="xpath")
        self.elementClick(locator=self._color, locatorType="name")
        self.clearField(locator=self._quantity)
        self.sendKeys(quantity, locator=self._quantity)
        self.elementClick(locator=self._add_to_cart, locatorType="xpath")
        self.waitForElement(locator=self._go_to_fulfill_the_order_button, locatorType="xpath")

    def getFewProductsToCart(self, quantity):
        self.getProductToCartPanda(quantity)
        self.elementClick(locator=self._continue_shopping_button, locatorType="xpath")
        self.waitForElement(locator=self._select_size, locatorType="name")
        time.sleep(2)
        self.getProductToCartFiona(quantity)
        self.elementClick(locator=self._go_to_fulfill_the_order_button, locatorType="xpath")
        self.waitForElement(locator="cart-detailed-totals",locatorType="class")

    def getFewProductsToCartSuccessful(self, quantity):
        self.getFewProductsToCart(quantity)
        num = self.driver.find_element(By.XPATH, self._num_of_products_in_cart).text
        if str((quantity*2)) in str(num):
            result = True
        else:
            result = False
        return result

    def priceOfProductsInBasket(self,quantity):
        self.getFewProductsToCart(quantity)
        elements = self.driver.find_elements(By.XPATH, "//div[@class='current-price']/span[@class='price']")
        prices = []
        for el in elements:
            price = el.text
            price = price.replace("zł", "")
            price = price.replace(",",".")
            price = price.rstrip()
            price = float(price)
            price = format(price,".2f")
            prices.append(price)
        numOfProducts = self.driver.find_elements(By.NAME, "product-quantity-spin")
        numsOfProducts = []
        for num in numOfProducts:
            number = num.get_attribute("value")
            number = float(number)
            number = format(number,".2f")
            numsOfProducts.append(number)
        multiplyProducts = []
        for i in range(0,len(prices)):
            multiply = float(numsOfProducts[i])*float(prices[i])
            multiplyProducts.append(multiply)
        sumOfProducts = sum(multiplyProducts)
        sumOfProductss = format(sumOfProducts,".2f")
        sumNum = self.driver.find_element(By.XPATH, "//div[@id='cart-subtotal-products']/span[@class='value']").text.replace("zł","")
        sumNum = sumNum.replace(",",".")
        if float(sumOfProductss) == float(sumNum):
            result = True
        else:
            result = False
        return result

    def deleteFromCart(self):
        self.getFewProductsToCart(quantity=1)
        self.elementClick(locator=self._go_to_fulfill_the_order_button, locatorType="xpath")
        self.waitForElement(locator="cart-detailed-totals", locatorType="class")
        quantityOfProducts = self.driver.find_elements(By.XPATH, self._products_in_cart)
        quantity1 = len(quantityOfProducts)
        self.elementClick(locator=self._first_product_trashcan, locatorType="xpath")
        time.sleep(2)
        quantityOfProducts2 = self.driver.find_elements(By.XPATH, self._products_in_cart)
        quantity2 = len(quantityOfProducts2)
        if quantity1 > quantity2:
            result = True
        else:
            result = False
        return result

    def changeQuantity(self):
        self.getProductToCartPanda(quantity=2)
        self.elementClick(locator=self._go_to_fulfill_the_order_button, locatorType="xpath")
        self.waitForElement(locator="cart-detailed-totals", locatorType="class")
        firstPrice = self.driver.find_element(By.XPATH, "//div[@id='cart-subtotal-products']/span[@class='value']").text
        price1 = firstPrice.replace("zł", "")
        price1 = price1.replace(",",".")
        price1 = float(price1)
        price1 = format(price1, ".2f")
        self.elementClick(locator=self._touchspin_down, locatorType="xpath")
        time.sleep(2)
        secondPrice = self.driver.find_element(By.XPATH, "//div[@id='cart-subtotal-products']/span[@class='value']").text
        price2 = secondPrice.replace("zł", "")
        price2 = price2.replace(",",".").rstrip()
        price2 = float(price2)
        price2 = format(price2,".2f")
        if float(price1) > float(price2):
            result = True
        else:
            result = False
        return result
class DiscountsPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.nav = NavigationPage(driver)
        self.lp = LoginPage(driver)

    #Loctors
    _discount_info_clothes_page = "//div[@class='products row']//span[@class='discount-percentage discount-product']"  #byXpath
    _panda_tshirt = "//div[@id='js-product-list']/div[@class='products row']//a[contains(text(),'T-shirt Panda')]"  #byXpath
    _discount_info_element = "//div[@class='product-prices']//span[@class='discount discount-percentage']"
    _panda_tshirt_current_price = "//section[@id='main']//div[@class='product-prices']/div[2]//span[1]"
    _panda_tshirt_regular_price = "//div[@class='product-prices']//span[@class='regular-price']"

    def priceCheck(self, discountnum):
        currentPrice = self.driver.find_element(
            By.XPATH,
            self._panda_tshirt_current_price).get_attribute("content")
        currentPrice = currentPrice.replace(",", ".")
        regularPrice = self.driver.find_element(
            By.XPATH, self._panda_tshirt_regular_price).text
        regularPrice = regularPrice.replace("zł", "")
        regularPrice = regularPrice.replace(",", ".")
        discount = float(regularPrice) * float(discountnum)
        if (float(regularPrice) - float(discount)) == float(currentPrice):
            return True
        return False

    def discountForLoggedInClientSuccessful(self, email, password,
                                            discountnum):
        self.lp.login(email, password)
        self.nav.goToClothesPage()
        self.waitForElement(locator=self._panda_tshirt, locatorType='xpath')
        self.elementClick(locator=self._panda_tshirt, locatorType='xpath')
        discountInfo = self.isElementPresent(
            locator=self._discount_info_element, locatorType='xpath')
        if discountInfo and self.priceCheck(discountnum):
            result = True
        else:
            result = False
        self.lp.logout()
        return result

    def discountForLoggedInClientFailed(self):
        self.nav.goToClothesPage()
        self.waitForElement(locator=self._panda_tshirt, locatorType='xpath')
        self.elementClick(locator=self._panda_tshirt, locatorType='xpath')
        result = self.isElementPresent(locator=self._discount_info_element,
                                       locatorType='xpath')
        return result

    def discountInfoOnClothesPageElements(self, email, password, elementNum):
        self.lp.login(email, password)
        self.nav.goToClothesPage()
        self.waitForElement(
            locator=
            "//div[@id='js-product-list']/div[@class='products row']/article[1]",
            locatorType='xpath')
        discountInfo = self.driver.find_elements(
            By.XPATH, self._discount_info_clothes_page)
        if len(discountInfo) == elementNum:
            result = True
        else:
            result = False
        self.lp.logout()
        return result
Exemple #11
0
 def objectSetup(self, oneTimeSetUp):
     self.cp = CartPage(self.driver)
     self.lp = LoginPage(self.driver)
     self.ts = TestStatus(self.driver)
     self.nav = NavigationPage(self.driver)
     self.sd = SeleniumDriver(self.driver)
 def objectSetup(self, oneTimeSetUp):
     self.ap = AccountPage(self.driver)
     self.ts = TestStatus(self.driver)
     self.nav = NavigationPage(self.driver)
class AccountTests(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)

    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.ap = AccountPage(self.driver)
        self.ts = TestStatus(self.driver)
        self.nav = NavigationPage(self.driver)

    # @pytest.mark.run(order=1)
    # def test_registerFormElementsValidation(self):
    #     self.log.info("Validation of elements of a customer registration form successful")
    #     result = self.ap.registerFormElementsValidation()
    #     assert result == True

    @pytest.mark.run(order=2)
    def test_createNewAccountFailedEmail(self):
        self.nav.backToHomePage()
        self.log.info(
            "Created a new customer account unsuccessful by providing an invalid email address"
        )
        result = self.ap.createNewAccountFailed(firstname="Jan",
                                                lastname="Kowalski",
                                                email="*****@*****.**",
                                                password="******")
        assert result == True

    @pytest.mark.run(order=3)
    def test_createNewAccountFailedFirstname(self):
        self.nav.backToHomePage()
        email = "test" + str(round(time.time() * 1000)) + "@test.com"
        self.log.info(
            "Created a new customer account unsuccessful by providing an invalid firstname"
        )
        result = self.ap.createNewAccountFailed(firstname="123@$",
                                                lastname="Kowalski",
                                                email=email,
                                                password="******")
        assert result == True

    @pytest.mark.run(order=4)
    def test_createNewAccountFailedLastname(self):
        self.nav.backToHomePage()
        email = "test" + str(round(time.time() * 1000)) + "@test.com"
        self.log.info(
            "Created a new customer account unsuccessful by providing an invalid firstname"
        )
        result = self.ap.createNewAccountFailed(firstname="Jan",
                                                lastname="$@23",
                                                email=email,
                                                password="******")
        assert result == True

    @pytest.mark.run(order=5)
    def test_createNewAccountSuccessful(self):
        self.nav.backToHomePage()
        self.log.info("Created a new customer account successful")
        email = "test" + str(round(time.time() * 1000)) + "@test.com"
        result = self.ap.createNewAccountSuccessful(firstname="Jan",
                                                    lastname="Kowalski",
                                                    email=email,
                                                    password="******")
        assert result == True
        self.ts.markFinal(
            "test_createNewAccountSuccessful", result,
            "Created a new customer account successful "
            "verification SUCCESSED")
Exemple #14
0
class CheckoutTests(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)

    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.chp = CheckoutPage(self.driver)
        self.lp = LoginPage(self.driver)
        self.ts = TestStatus(self.driver)
        self.nav = NavigationPage(self.driver)
        self.sd = SeleniumDriver(self.driver)

    @pytest.mark.run(order=1)
    def test_checkoutGuestFormPersonalInformationSuccessful(self):
        self.log.info("Personal Information form for guest client successed")
        email = email = "test" + str(round(time.time() * 1000)) + "@test.com"
        result = self.chp.checkoutGuestFormPersonalInformationSuccessful(
            firstname="Adam",
            lastname="Kowalski",
            email=email,
            password="******")
        assert result == True

    @pytest.mark.run(order=2)
    def test_checkoutGuestFormPersonalInformationFailed(self):
        self.log.info(
            "Personal Information form for guest client failed due to wrong email"
        )
        self.nav.clearCartAndGoToMainPage()
        self.lp.logOut()
        result = self.chp.checkoutGuestFormPersonalInformationFailed(
            firstname="Adam",
            lastname="Kowalski",
            email="*****@*****.**",
            password="******")
        assert result == True

    @pytest.mark.run(order=3)
    def test_addressFormSuccessful(self):
        self.log.info("Address form for guest client successful")
        self.nav.clearCartAndGoToMainPage()
        self.lp.logOut()
        email = email = "test" + str(round(time.time() * 1000)) + "@test.com"
        result = self.chp.addressFormSuccessful(firstname="Adam",
                                                lastname="Kowalski",
                                                email=email,
                                                password="******",
                                                address="Testowa 1/2",
                                                postcode="00-000",
                                                city="Warszawa",
                                                phone="500500500")
        assert result == True

    @pytest.mark.run(order=4)
    def test_addressFormFailed(self):
        self.log.info(
            "Address form for guest client failed due to wrong postcode")
        self.nav.clearCartAndGoToMainPage()
        self.lp.logOut()
        email = email = "test" + str(round(time.time() * 1000)) + "@test.com"
        result = self.chp.addressFormFailed(firstname="Adam",
                                            lastname="Kowalski",
                                            email=email,
                                            password="******",
                                            address="Testowa 1/2",
                                            postcode="00",
                                            city="Warszawa",
                                            phone="500500500")
        assert result == True

    @pytest.mark.run(order=5)
    def test_addressFormFailed2(self):
        self.log.info(
            "Address form for guest client failed due to wrong phone number")
        self.nav.clearCartAndGoToMainPage()
        self.lp.logOut()
        email = email = "test" + str(round(time.time() * 1000)) + "@test.com"
        result = self.chp.addressFormFailed(firstname="Adam",
                                            lastname="Kowalski",
                                            email=email,
                                            password="******",
                                            address="Testowa 1/2",
                                            postcode="00-000",
                                            city="Warszawa",
                                            phone="abc")
        assert result == True

    @pytest.mark.run(order=6)
    def test_deliverySuccessed(self):
        self.log.info("Delivery form successed")
        self.nav.clearCartAndGoToMainPage()
        self.lp.logOut()
        email = email = "test" + str(round(time.time() * 1000)) + "@test.com"
        result = self.chp.deliverySuccessed(firstname="Adam",
                                            lastname="Kowalski",
                                            email=email,
                                            password="******",
                                            address="Testowa 1/2",
                                            postcode="00-000",
                                            city="Warszawa",
                                            phone="500500500")
        assert result == True

    @pytest.mark.run(order=7)
    def test_paymentConditionsAcceptanceVerification(self):
        self.log.info("Payment conditions acceptance verification successful")
        self.nav.clearCartAndGoToMainPage()
        self.lp.logOut()
        email = email = "test" + str(round(time.time() * 1000)) + "@test.com"
        result = self.chp.paymentConditionsAcceptanceVerification(
            firstname="Adam",
            lastname="Kowalski",
            email=email,
            password="******",
            address="Testowa 1/2",
            postcode="00-000",
            city="Warszawa",
            phone="500500500")
        assert result == True

    @pytest.mark.run(order=8)
    def test_paymentSuccessed(self):
        self.log.info("Address form for guest client successful")
        self.nav.clearCartAndGoToMainPage()
        self.lp.logOut()
        email = email = "test" + str(round(time.time() * 1000)) + "@test.com"
        result = self.chp.paymentSuccessed(firstname="Adam",
                                           lastname="Kowalski",
                                           email=email,
                                           password="******",
                                           address="Testowa 1/2",
                                           postcode="00-000",
                                           city="Warszawa",
                                           phone="500500500")
        assert result == True

    @pytest.mark.run(order=9)
    def test_personalInfVerificationLoggedInClient(self):
        self.log.info(
            "Personal information form for logged in client verification successful"
        )
        self.nav.clearCartAndGoToMainPage()
        self.lp.logOut()
        result = self.chp.personalInfVerificationLoggedInClient(
            username="******",
            email="*****@*****.**",
            password="******")
        assert result == True

    @pytest.mark.run(order=10)
    def test_addressVerificationLoggedInClient(self):
        self.log.info("Address form for logged in client successful")
        self.nav.backToHomePage()
        self.lp.logOut()
        address = "Ewa Kowalska\nul. Testowa\n00-000 Warszawa\nPolska\n600600600"
        result = self.chp.addressVerificationLoggedInClient(
            address=address, email="*****@*****.**", password="******")
        assert result == True

    @pytest.mark.run(order=10)
    def test_addNewAddressLoggedInClient(self):
        self.log.info("Add address form for logged in client successful")
        self.nav.backToHomePage()
        self.lp.logOut()
        address = "Testowa" + str(round(time.time() * 1000)) + "/2"
        result = self.chp.addNewAddressLoggedinClient(email="*****@*****.**",
                                                      password="******",
                                                      address=address,
                                                      postcode="00-000",
                                                      city="Warszawa",
                                                      phone="600600600")
        assert result == True
        self.ts.markFinal(
            "test_addNewAddressLoggedinClient", result,
            "Add address form for logged in client successful"
            "verification SUCCESSED")
Exemple #15
0
 def objectSetup(self, oneTimeSetUp):
     self.sp = productSearch(self.driver)
     self.ts = TestStatus(self.driver)
     self.nav = NavigationPage(self.driver)
class ContactPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.nav = NavigationPage(driver)

    # Locators
    _contact_page = "link-static-page-contact-2]"  #byID
    _contact_form = "contact-form"  #byclass
    _contact_address = "data"  #byclass
    _contact_email = "//div[@id='left-column']//a[@href='mailto:[email protected]']"  #byxpath
    _subject_list = "id_contact"  #byname
    _subject_1 = "//select[@name='id_contact']//option[1]"  #byxpath
    _email = "from"  #byname
    _message = "message"  #byname
    _send = "submitMessage"  #byname
    _contact_number = "500500500"  #bylink
    _contact_failed = "//section[@id='content']//li[contains(text(),'Wiadomość nie może być pusta')]"  #byxpath
    _contact_success = "//section[@id='content']//li[contains(text(),'Twoja wiadomość została pomyślnie wysłana do obsługi.')]"  #byxpath
    _newsletter_email_input = "email"  #byname
    _submit_newsletter = "//input[@name='submitNewsletter'][1]"  #byxpath
    _submit_newsletter_success = "//p[contains(text(), 'Zarejestrowano do subskrypcji')]"  #byxpath
    _submit_newsletter_failed = "//p[contains(text(), 'Ten email już jest w bazie')]"  #byxpath
    _maine_page_phonenumber = "//div[@id='contact-link']/span"  #byxpath

    def contactEmail(self, contactemail):
        self.nav.goToContactPage()
        contact_email = self.getElement(locator=self._contact_email,
                                        locatorType="xpath")
        email = contact_email.text
        if email == contactemail:
            result = True
        else:
            result = False
        return result

    def contactAddress(self, address):
        self.nav.goToContactPage()
        caddress = self.getElement(locator=self._contact_address,
                                   locatorType="class")
        contactAddress = caddress.text.lower()
        if contactAddress == address:
            result = True
        else:
            result = False
        return result

    def contactNumber(self, phonenumber):
        self.nav.goToContactPage()
        cnumber = self.getElement(locator=self._contact_number,
                                  locatorType="link")
        contactNumber = cnumber.text
        if contactNumber == phonenumber:
            result = True
        else:
            result = False
        return result

    def contactForm(self, email, message):
        self.nav.goToContactPage()
        self.elementClick(locator=self._subject_list, locatorType="name")
        self.waitForElement(locator=self._subject_1, locatorType="xpath")
        self.elementClick(locator=self._subject_1, locatorType="xpath")
        self.sendKeys(email, locator=self._email, locatorType="name")
        self.sendKeys(message, locator=self._message, locatorType="name")
        self.elementClick(locator=self._send, locatorType="name")

    def contactFormSuccess(self, email, message):
        self.contactForm(email, message)
        self.waitForElement(locator=self._contact_success, locatorType="xpath")
        result = self.isElementPresent(locator=self._contact_success,
                                       locatorType="xpath")
        return result

    def contactFormFailed(self, email, message):
        self.contactForm(email, message)
        self.waitForElement(locator=self._contact_failed, locatorType="xpath")
        result = self.isElementPresent(locator=self._contact_failed,
                                       locatorType="xpath")
        return result

    def newsletter(self, email):
        self.nav.goToContactPage()
        self.sendKeys(email,
                      locator=self._newsletter_email_input,
                      locatorType="name")
        self.elementClick(locator=self._submit_newsletter, locatorType="xpath")

    def newsletterSuccessed(self, email):
        self.newsletter(email)
        self.waitForElement(locator=self._submit_newsletter_success,
                            locatorType="xpath")
        result = self.isElementPresent(locator=self._submit_newsletter_success,
                                       locatorType="xpath")
        return result

    def newsletterFailed(self, email):
        self.newsletter(email)
        self.waitForElement(locator=self._submit_newsletter_failed,
                            locatorType="xpath")
        result = self.isElementPresent(locator=self._submit_newsletter_failed,
                                       locatorType="xpath")
        return result

    def maincontactNumber(self, number):
        num = self.getElement(locator=self._maine_page_phonenumber,
                              locatorType="xpath")
        cnum = num.text
        if cnum == number:
            result = True
        else:
            result = False
        return result