Ejemplo n.º 1
0
 def update_quantity(self, new_qty):
     path = parser.get_value('QtyBox')
     qty_box = self.driver.find_element_by_id(path)
     current_qty = qty_box.get_attribute('value')
     self.assertEqual(int(current_qty), 1)
     qty_box.send_keys(Keys.BACKSPACE + str(new_qty))
     path = parser.get_value('UpdateButton')
     self.driver.find_element_by_xpath(path).click()
     return self.get_product_from_cart()
Ejemplo n.º 2
0
 def get_product_from_cart(self):
     path = parser.get_value('ProductNameCart')
     product_name_cart = self.driver.find_element_by_xpath(path).text
     path = parser.get_value('PriceCart')
     price_cart = self.driver.find_element_by_xpath(path).text
     currency_cart, amount_cart = self.parse_price(price_cart)
     path = parser.get_value('CartTotal')
     total = self.driver.find_element_by_xpath(path).text
     _, amount_total = self.parse_price(total)
     product_cart = {
         'name': product_name_cart,
         'price': amount_cart,
         'currency': currency_cart,
         'total': amount_total
     }
     self.assertIn('premium security', product_cart['name'].lower())
     return product_cart
Ejemplo n.º 3
0
 def change_currency(self, currency):
     path = parser.get_value('CurrencyCart')
     self.driver.find_element_by_xpath(path).click()
     path = path + '/option'
     currencies = self.driver.find_elements_by_xpath(path)
     for i in range(len(currencies)):
         if currencies[i].get_attribute('value') == currency:
             self.driver.find_element_by_xpath(path+f'[{str(i+1)}]').click()
             return
Ejemplo n.º 4
0
 def add_product_to_cart(self):
     self.accept_cookies()
     self.log.info('Navigating to Home -> See solutions')
     path = parser.get_value('SeeSolutions')
     self.driver.find_element_by_xpath(path).click()
     self.assertIn('solutions', self.driver.current_url)
     self.log.info('Clicking on Multiplatform')
     path = parser.get_value('MultiplatformButton')
     self.driver.find_element_by_id(path).click()
     sleep(2)
     path = parser.get_value('MultiplatformSelected')
     attr = self.driver.find_element_by_xpath(path).get_attribute("class")
     self.log.info('Check that Multiplatform was correctly selected')
     self.assertIn('active', attr)
     path = parser.get_value('PricePLP')
     price_plp = self.driver.find_element_by_xpath(path).text
     path = parser.get_value('ProductNamePLP')
     product_name_plp = self.driver.find_element_by_xpath(path).text
     currency_plp, amount_plp = self.parse_price(price_plp)
     product_plp = {
         'name': product_name_plp,
         'price': amount_plp,
         'currency': currency_plp
     }
     self.log.info('Checking selected product corresponds with the requirements')
     self.assertIn('premium security', product_plp['name'].lower())
     self.log.info('Adding product to cart')
     path = parser.get_value('BuyNowMP')
     self.driver.find_element_by_xpath(path).click()
     self.log.info('Check redirect to checkout')
     self.assertIn('/store.bitdefender.com/order/checkout.php', self.driver.current_url)
     return product_plp
Ejemplo n.º 5
0
 def accept_cookies(self):
     path = parser.get_value('AcceptCookies')
     self.driver.find_element_by_xpath(path).click()
Ejemplo n.º 6
0
 def remove_product_from_cart(self):
     path = parser.get_value('RemoveFromCart')
     self.driver.find_element_by_id(path).click()
     sleep(3)