Exemplo n.º 1
0
def checkout_selenium(driver, timeout, promo_locale, target_gpu, notifications,
                      notification_queue):
    logging.info(
        f"Checking {promo_locale} availability for {target_gpu['name']} using selenium..."
    )
    product_loaded = nvidia.get_product_page(driver, promo_locale, target_gpu)
    if product_loaded:
        gpu_available = nvidia.check_availability(driver, timeout)
        if gpu_available:
            logging.info(f"Found available GPU: {target_gpu['name']}")
            if notifications['availability']['enabled']:
                driver.save_screenshot(const.SCREENSHOT_FILE)
                notification_queue.put('availability')
            added_to_basket = False
            while not added_to_basket:
                logging.info(f'Trying to add to basket...')
                added_to_basket = nvidia.add_to_basket(driver, timeout)
                if not added_to_basket:
                    logging.info(f'Add to basket click failed, trying again!')
            logging.info(f'Add to basket click suceeded!')
            if notifications['add-to-basket']['enabled']:
                driver.save_screenshot(const.SCREENSHOT_FILE)
                notification_queue.put('add-to-basket')
            logging.info('Going to checkout page...')
            checkout_reached = nvidia.to_checkout(driver, timeout,
                                                  promo_locale,
                                                  notification_queue)
            if checkout_reached:
                return True
            else:
                logging.error(
                    'Lost basket and failed to checkout, trying again...')
                return False
        else:
            logging.info('GPU currently not available')
        return False
    else:
        return False
Exemplo n.º 2
0
                notification_queue.put('availability')

            added_to_basket = False
            while not added_to_basket:
                logging.info(f'Trying to add to basket...')
                added_to_basket = nvidia.add_to_basket(driver, timeout)
                if not added_to_basket:
                    logging.info(f'Add to basket click failed, trying again!')

            logging.info(f'Add to basket click suceeded!')
            if notification_config['add-to-basket']['enabled']:
                driver.save_screenshot(const.SCREENSHOT_FILE)
                notification_queue.put('add-to-basket')

            logging.info('Going to checkout page...')
            checkout_reached = nvidia.to_checkout(
                driver, timeout, locale, notification_queue)
            if checkout_reached:
                if payment_method == 'credit-card':
                    nvidia.checkout_guest(
                        driver, timeout, customer, auto_submit)
                else:
                    nvidia.checkout_paypal(driver, timeout),

                logging.info('Checkout successful!')
                if notification_config['checkout']['enabled']:
                    driver.save_screenshot(const.SCREENSHOT_FILE)
                    notification_queue.put('checkout')

                if auto_submit:
                    nvidia.click_recaptcha(driver, timeout)
                    order_submitted = nvidia.submit_order(driver, timeout)
Exemplo n.º 3
0
                notify.send_notifications(target_gpu, 'availability',
                                          notifications)
            added_to_basket = False
            while not added_to_basket:
                logging.info(f'Trying to add to basket...')
                added_to_basket = nvidia.add_to_basket(driver, timeout)
                if not added_to_basket:
                    logging.info(f'Add to basket click failed, trying again!')

            logging.info(f'Add to basket click suceeded!')
            if notifications['add-to-basket']['enabled']:
                driver.save_screenshot(SCREENSHOT_FILE)
                notify.send_notifications(target_gpu, 'add-to-basket',
                                          notifications)
            logging.info('Going to checkout page...')
            checkout_reached = nvidia.to_checkout(driver, timeout, locale)
            if checkout_reached:
                if payment_method == 'credit-card':
                    nvidia.checkout_guest(driver, timeout, customer,
                                          auto_submit)
                else:
                    nvidia.checkout_paypal(driver, timeout),

                logging.info('Checkout successful!')
                if notifications['checkout']['enabled']:
                    driver.save_screenshot(SCREENSHOT_FILE)
                    notify.send_notifications(target_gpu, 'checkout',
                                              notifications)

                if auto_submit:
                    nvidia.click_recaptcha(driver, timeout)