예제 #1
0
 def __init__(self, driver):
     self.driver = driver
     self.action = TouchAction(self.driver)
     self.ew = ElementWrapper(self.driver)
     self.period_filter = PeriodFilter(self.driver)
     self.rs = Resolutions(self.driver)
     self.timeline_general = TimelineGeneral(self.driver)
     self.transaction_detail = TransactionDetail(self.driver)
예제 #2
0
 def __init__(self, driver):
     self.driver = driver
     self.ew = ElementWrapper(self.driver)
     self.email_password = EmailPassword(self.driver)
     self.facebook = Facebook(self.driver)
     self.google = Google(self.driver)
     self.marketing_dialog = MarketingDialog(self.driver)
     self.more_general = MoreGeneral(self.driver)
     self.timeline_general = TimelineGeneral(self.driver)
     self.user_profile = UserProfile(self.driver)
     self.welcome_screen = WelcomeScreen(self.driver)
예제 #3
0
class TransactionValidator:
    def __init__(self, driver):
        self.driver = driver
        self.action = TouchAction(self.driver)
        self.ew = ElementWrapper(self.driver)
        self.period_filter = PeriodFilter(self.driver)
        self.rs = Resolutions(self.driver)
        self.timeline_general = TimelineGeneral(self.driver)
        self.transaction_detail = TransactionDetail(self.driver)

    def get_all_attributes(self):
        """ Getting all attributes of transaction
        :return: dict
        """
        all_attributes = {
            "category": self.transaction_detail.get_category(),
            "amount": self.transaction_detail.get_amount(),
            "wallet_amount": self.transaction_detail.get_wallet_amount(),
            "currency": self.transaction_detail.get_currency(),
            "wallet": self.transaction_detail.get_wallet("transaction"),
            "start_date": self.transaction_detail.get_date("start"),
            "note": self.transaction_detail.get_note(),
            "labels": self.transaction_detail.get_labels(True),
            "photo": self.transaction_detail.get_photo(),
            "reminder": self.transaction_detail.get_reminder(),
        }

        return all_attributes

    def is_transaction_on_timeline(self, attributes):
        """ Checking if transaction is visible inside Timeline or Scheduled section
        :param attributes: dict
        :return: bool
        """
        transaction_locator = f"regular/" \
                              f"{attributes['category']}/" \
                              f"{self.adjust_amounts(attributes['amount'], attributes['wallet_amount'])[0]}/" \
                              f"{self.adjust_amounts(attributes['amount'], attributes['wallet_amount'])[1]}/" \
                              f"{attributes['wallet']}/" \
                              f"undefined/" \
                              f"{self.adjust_note(attributes['note'])}/" \
                              f"{self.adjust_labels(attributes['labels'])}/" \
                              f"{str(attributes['photo']).lower()}/" \
                              f"undefined/" \
                              f"undefined/" \
                              f"{self.adjust_reminder(attributes['reminder'])}"

        print(f'LOCATOR: {transaction_locator}')

        self.prepare_timeline(attributes['start_date'], "undefined")

        android_timeout = time.time() + 60
        ios_timeout = time.time() + 5
        res = self.rs.get_resolution()
        is_transaction_present = self.ew.is_element_present(
            transaction_locator)

        while is_transaction_present is False:
            if PLATFORM == "Android":
                self.swipe_android(res)
                is_transaction_present = self.ew.is_element_present(
                    transaction_locator)
                if time.time() > android_timeout:
                    return False
            else:
                is_transaction_present = self.ew.is_element_present(
                    transaction_locator)
                if time.time() > ios_timeout:
                    return False
        return True

    def adjust_amounts(self, amount, wallet_amount):
        """ Adjusting amount for transaction locator
        :param amount: str
        :param wallet_amount: str
        :return: list of str
        """
        if wallet_amount is None:
            amount_final = amount
            wallet_amount_final = "undefined"
        else:
            amount_final = ""
            for i in wallet_amount:
                if i in [
                        "-", ".", "0", "1", "2", "3", "4", "5", "6", "7", "8",
                        "9"
                ]:
                    amount_final = amount_final + i

            wallet_amount_final = "{:.2f}".format(float(amount))
        return ["{:.2f}".format(float(amount_final)), wallet_amount_final]

    def adjust_note(self, note):
        """ Adjusting note for transaction locator
        :param note: str
        :return: str
        """
        if note is None:
            note = ""
        return note

    def adjust_labels(self, labels):
        """ Adjusting labels for transaction locator
        :param labels: list of str
        :return: list of str
        """
        if len(labels) > 0:
            labels_final = ""
            for i in labels:
                labels_final = labels_final + f",{i}"
            labels_final = labels_final[1:]
        else:
            labels_final = "undefined"

        return labels_final

    def adjust_reminder(self, reminder):
        """ Adjusting reminder for transaction locator
        :param reminder: str
        :return: str
        """
        if reminder is None or reminder == "Never":
            return "undefined"
        else:
            return reminder

    def prepare_timeline(self, start_date, recurrence):
        """ Prepares timeline for transaction search. Opening scheduled screen if transaction has future date.
        :param start_date: str
        :param recurrence: str
        """
        self.ew.wait_till_element_is_visible(
            self.timeline_general.NAVIGATION_TIMELINE, 30)
        year, month, day = (int(x) for x in start_date.split('-'))
        date = datetime.date(year, month, day)
        today = datetime.date.today()

        if date > today or recurrence != "undefined":

            if self.ew.is_element_present(
                    self.timeline_general.SCHEDULED_SCREEN) is False:
                self.ew.wait_till_element_is_visible(
                    self.timeline_general.TRANSACTION_SECTION, 20)
                self.timeline_general.open_scheduled_section()
            else:
                if PLATFORM == "Android":
                    time.sleep(5)
                else:
                    time.sleep(2)

        elif date < today:
            self.period_filter.set_filter_period(
                self.period_filter.ALL_TIME_PERIOD)

    def swipe_android(self, resolution):
        """ Looks into past by swiping on android phones
        :param resolution: str
        :return:
        """
        self.action.long_press(None, self.rs.all_resolutions[f"{resolution}"]["x"],
                               self.rs.all_resolutions[f"{resolution}"]["transaction_timeline_up_y_start"]) \
            .move_to(None, self.rs.all_resolutions[f"{resolution}"]["x"],
                     self.rs.all_resolutions[f"{resolution}"]["transaction_timeline_up_y_end"]) \
            .release().perform()
예제 #4
0
class TransactionActions:
    EXISTING_TRANSACTION = "Existing Item: regular-undefined"
    EXISTING_TRANSACTION_TEMPLATES = [
        "Existing Item: regular-every day",
        "Existing Item: regular-every 2 days",
        "Existing Item: regular-every working day",
        "Existing Item: regular-every week",
        "Existing Item: regular-every 2 weeks",
        "Existing Item: regular-every 4 weeks",
        "Existing Item: regular-every month",
        "Existing Item: regular-every 2 months",
        "Existing Item: regular-every 3 months",
        "Existing Item: regular-every 6 months",
        "Existing Item: regular-every year"
    ]

    def __init__(self, driver):
        self.driver = driver
        self.ew = ElementWrapper(self.driver)
        self.timeline_general = TimelineGeneral(self.driver)
        self.transaction_detail = TransactionDetail(self.driver)
        self.transfer_destination_modal = TransferDestinationModal(self.driver)

    def create_transaction(self, transaction_type, category, amount, currency,
                           wallet, start_date, note, label, photo, recurrence,
                           end_date, reminder):
        """
        Opens create transaction screen and sets requested attributes
        :param transaction_type: str or None
        :param category: str or None
        :param amount: str or None
        :param currency: str or None
        :param wallet: str or None
        :param start_date: str or None
        :param note: str or None
        :param label: str or None
        :param photo: bool
        :param recurrence: str or None
        :param end_date: str or None
        :param reminder: str or None
        """
        self.timeline_general.open_transaction_create_screen()
        if transaction_type is not None:
            self.transaction_detail.set_type_of_transaction(transaction_type)
        self.transaction_detail.set_category(category)
        self.transaction_detail.set_amount(amount)
        if currency is not None:
            self.transaction_detail.set_currency(currency)
        if wallet is not None:
            self.transaction_detail.set_wallet(wallet, "transaction")
        if start_date is not None:
            self.transaction_detail.set_start_date(start_date)
        if note is not None:
            self.transaction_detail.set_note(note)
        if label is not None:
            self.transaction_detail.set_label(label)
        if photo is not None:
            self.transaction_detail.set_photo()
        if recurrence is not None:
            self.ew.wait_till_element_is_visible(
                self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)
            self.ew.swipe_if_element_not_present(
                self.transaction_detail.RECURRENCE)
            self.transaction_detail.set_recurrence(recurrence)
        if end_date is not None:
            self.ew.wait_till_element_is_visible(
                self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)
            self.ew.swipe_if_element_not_present(
                self.transaction_detail.END_DATE)
            self.transaction_detail.set_end_date(end_date)
        if reminder is not None:
            self.ew.wait_till_element_is_visible(
                self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)
            self.ew.swipe_if_element_not_present(
                self.transaction_detail.REMINDER)
            self.transaction_detail.set_reminder(reminder)
        self.ew.wait_till_element_is_visible(
            self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)

    def save_transaction(self):
        """Clicks on save transaction button"""
        self.ew.wait_and_tap_element(
            self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)
        if self.transfer_destination_modal.is_destination_modal_present(
        ) or self.transfer_destination_modal.is_origination_modal_present():
            self.transfer_destination_modal.create_as_new_transaction()

    def open_transaction(self):
        """Opens existing transaction, if there is no one, it creates transaction"""
        self.ew.wait_till_element_is_visible(
            self.timeline_general.OVERVIEW_BUTTON, 30)
        self.timeline_general.go_to_timeline()
        if self.ew.is_element_present(self.EXISTING_TRANSACTION) is False:
            self.create_transaction(transaction_type="random",
                                    category="random",
                                    amount="random",
                                    currency=None,
                                    wallet=None,
                                    start_date=None,
                                    note=None,
                                    label=None,
                                    photo=None,
                                    recurrence=None,
                                    end_date=None,
                                    reminder=None)
            self.save_transaction()
            self.ew.wait_till_element_is_visible(
                self.timeline_general.NAVIGATION_TIMELINE, 30)
        self.ew.wait_and_tap_element(self.EXISTING_TRANSACTION, 15)
        self.ew.wait_till_element_is_visible(
            self.transaction_detail.TRANSACTION_HEADER_TITLE, 15)

    def open_transaction_template(self):
        """Opens existing transaction template, if there is no one, it creates transaction"""
        self.ew.wait_till_element_is_visible(
            self.timeline_general.TRANSACTION_SECTION, 60)
        if self.ew.is_element_present(self.timeline_general.SCHEDULED) is True:
            self.timeline_general.open_scheduled_section()
            for i in self.EXISTING_TRANSACTION_TEMPLATES:
                if self.ew.is_element_present(i):
                    self.ew.tap_element(i)
                    break
                elif i == "Existing Item: regular-every year":
                    self.create_transaction(transaction_type="random",
                                            category="random",
                                            amount="random",
                                            currency=None,
                                            wallet=None,
                                            start_date=None,
                                            note=None,
                                            label=None,
                                            photo=None,
                                            recurrence="random",
                                            end_date=None,
                                            reminder=None)
                    self.save_transaction()
                    self.timeline_general.open_scheduled_section()
                    for i in self.EXISTING_TRANSACTION_TEMPLATES:
                        if self.ew.is_element_present(i):
                            self.ew.tap_element(i)
        else:
            self.create_transaction(transaction_type="random",
                                    category="random",
                                    amount="random",
                                    currency=None,
                                    wallet=None,
                                    start_date=None,
                                    note=None,
                                    label=None,
                                    photo=None,
                                    recurrence="random",
                                    end_date=None,
                                    reminder=None)
            self.save_transaction()
            self.timeline_general.open_scheduled_section()
            for i in self.EXISTING_TRANSACTION_TEMPLATES:
                if self.ew.is_element_present(i):
                    self.ew.tap_element(i)

    def edit_transaction(self, transaction_type, category, amount, wallet,
                         start_date, note, label, photo, recurrence, end_date,
                         reminder):
        """Edits requested attributes on transaction detail screen
        :param transaction_type: str or None
        :param category: str or None
        :param amount: str or None
        :param wallet: str or None
        :param start_date: str or None
        :param note: str or None
        :param label: str or None
        :param photo: bool
        :param recurrence: str or None
        :param end_date: str or None
        :param reminder: str or None
        """
        if transaction_type is not None:
            self.ew.wait_and_tap_element(self.transaction_detail.CATEGORY_ICON,
                                         10)
            if transaction_type == "transfer":
                self.transaction_detail.set_type_to_transfer()
            else:
                self.transaction_detail.set_type_of_transaction(
                    transaction_type)
                self.transaction_detail.set_category("random")
        if category is not None:
            self.ew.wait_and_tap_element(self.transaction_detail.CATEGORY_ICON,
                                         10)
            self.transaction_detail.set_category(category)
        if amount is not None:
            self.ew.wait_and_tap_element(self.transaction_detail.AMOUNT_INPUT,
                                         10)
            self.ew.wait_till_element_is_visible(
                self.transaction_detail.NUMPAD_CLEAR, 10)
            for i in range(6):
                self.ew.tap_element(self.transaction_detail.NUMPAD_CLEAR)
            self.transaction_detail.set_amount(amount)
        if wallet is not None:
            self.transaction_detail.set_wallet(wallet, "transaction")
        if start_date is not None:
            self.transaction_detail.set_start_date(start_date)
        if note is not None:
            try:
                self.ew.wait_till_element_is_visible(
                    self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)
                self.ew.get_element(
                    self.transaction_detail.EXISTING_NOTE).clear()
            except NoSuchElementException:
                pass
            self.transaction_detail.set_note(note)
        if label is not None:
            self.transaction_detail.set_label(label)
        if photo is not None:
            self.transaction_detail.set_photo()
        if recurrence is not None:
            self.ew.wait_till_element_is_visible(
                self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)
            self.ew.swipe_if_element_not_present(
                self.transaction_detail.RECURRENCE)
            self.transaction_detail.set_recurrence(recurrence)
        if end_date is not None:
            self.ew.wait_till_element_is_visible(
                self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)
            self.ew.swipe_if_element_not_present(
                self.transaction_detail.END_DATE)
            self.transaction_detail.set_end_date(end_date)
        if reminder is not None:
            self.ew.wait_till_element_is_visible(
                self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)
            self.ew.swipe_if_element_not_present(
                self.transaction_detail.REMINDER)
            self.transaction_detail.set_reminder(reminder)
        self.ew.wait_till_element_is_visible(
            self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)

    def delete_transaction(self):
        """Deletes transaction from transaction detail screen"""
        self.ew.wait_and_tap_element(self.transaction_detail.TRASH_ICON, 10)
        self.ew.wait_and_tap_element(self.transaction_detail.DELETE_BUTTON, 10)
예제 #5
0
 def __init__(self, driver):
     self.driver = driver
     self.ew = ElementWrapper(self.driver)
     self.timeline_general = TimelineGeneral(self.driver)
     self.transaction_detail = TransactionDetail(self.driver)
     self.transfer_destination_modal = TransferDestinationModal(self.driver)
예제 #6
0
class TransferActions():
    EXISTING_TRANSFER = "Existing Item: transfer-undefined"
    EXISTING_TRANSFER_TEMPLATES = ["Existing Item: transfer-every day", "Existing Item: transfer-every 2 days",
                                   "Existing Item: transfer-every working day", "Existing Item: transfer-every week",
                                   "Existing Item: transfer-every 2 weeks", "Existing Item: transfer-every 4 weeks",
                                   "Existing Item: transfer-every month", "Existing Item: transfer-every 2 months",
                                   "Existing Item: transfer-every 3 months", "Existing Item: transfer-every 6 months",
                                   "Existing Item: transfer-every year"]

    def __init__(self, driver):
        self.driver = driver
        self.ew = ElementWrapper(self.driver)
        self.timeline_general = TimelineGeneral(self.driver)
        self.transaction_actions = TransactionActions(self.driver)
        self.transaction_detail = TransactionDetail(self.driver)

    def create_transfer(self, amount, outgoing_wallet, incoming_wallet, start_date, note, recurrence, end_date,
                        reminder):
        """ Opens create transfer screen and sets requested attributes
        :param amount: str or None
        :param outgoing_wallet: str or None
        :param incoming_wallet: str or None
        :param start_date: str or None
        :param note: str or None
        :param recurrence: str or None
        :param end_date: str or None
        :param reminder: str or None
        """
        self.timeline_general.open_transaction_create_screen()
        self.transaction_detail.set_type_to_transfer()
        self.transaction_detail.set_amount(amount)
        if outgoing_wallet is not None:
            self.transaction_detail.set_wallet(outgoing_wallet, "transfer_outgoing")
        if incoming_wallet is not None:
            self.transaction_detail.set_wallet(incoming_wallet, "transfer_incoming")
        if start_date is not None:
            self.transaction_detail.set_start_date(start_date)
        if note is not None:
            self.transaction_detail.set_note(note)
        if recurrence is not None:
            self.transaction_detail.set_recurrence(recurrence)
        if end_date is not None:
            self.transaction_detail.set_end_date(end_date)
        if reminder is not None:
            self.transaction_detail.set_reminder(reminder)

    def open_transfer(self):
        """Opens existing transfer, if there is no one, it creates transfer"""
        self.timeline_general.go_to_timeline()
        self.ew.wait_till_element_is_visible(self.timeline_general.ADD_TRANSACTION_BUTTON, 30)
        print(self.ew.is_element_present(self.EXISTING_TRANSFER))
        if self.ew.is_element_present(self.EXISTING_TRANSFER) is False:
            self.create_transfer(amount="random", outgoing_wallet=None, incoming_wallet=None, start_date=None,
                                 note=None, recurrence=None, end_date=None, reminder=None)
            self.transaction_actions.save_transaction()
            self.ew.wait_till_element_is_visible(self.timeline_general.NAVIGATION_TIMELINE, 30)
        self.ew.wait_and_tap_element(self.EXISTING_TRANSFER, 15)
        self.ew.wait_till_element_is_visible(self.transaction_detail.TRANSACTION_HEADER_TITLE, 15)

    def open_transfer_template(self):
        """Opens existing transfer template"""
        self.ew.wait_till_element_is_visible(self.timeline_general.TRANSACTION_SECTION, 60)
        if self.ew.is_element_present(self.timeline_general.SCHEDULED) is True:
            self.timeline_general.open_scheduled_section()
            for i in self.EXISTING_TRANSFER_TEMPLATES:
                if self.ew.is_element_present(i):
                    self.ew.tap_element(i)
                    break
                elif i == "Existing Item: transfer-every year":
                    self.create_transfer(amount="random", outgoing_wallet=None, incoming_wallet=None, start_date=None,
                                         note=None, recurrence="random", end_date=None, reminder=None)
                    self.transaction_actions.save_transaction()
                    self.timeline_general.open_scheduled_section()
                    for i in self.EXISTING_TRANSFER_TEMPLATES:
                        if self.ew.is_element_present(i):
                            self.ew.tap_element(i)
        else:
            self.create_transfer(amount="random", outgoing_wallet=None, incoming_wallet=None, start_date=None,
                                 note=None, recurrence="random", end_date=None, reminder=None)
            self.transaction_actions.save_transaction()
            self.timeline_general.open_scheduled_section()
            for i in self.EXISTING_TRANSFER_TEMPLATES:
                if self.ew.is_element_present(i):
                    self.ew.tap_element(i)

    def edit_transfer(self, transaction_type, amount, outgoing_wallet, incoming_wallet, start_date, note, recurrence,
                      end_date, reminder):
        """ Edits requested attributes on transfer detail screen
        :param transaction_type: str or None
        :param amount: str or None
        :param outgoing_wallet: str or None
        :param incoming_wallet: str or None
        :param start_date: str or None
        :param note: str or None
        :param recurrence: str or None
        :param end_date: str or None
        :param reminder: str or None
        """
        if transaction_type is not None:
            self.ew.tap_element(self.transaction_detail.CATEGORY_ICON)
            if transaction_type == "transfer":
                self.transaction_detail.set_type_to_transfer()
            else:
                self.transaction_detail.set_type_of_transaction(transaction_type)
                self.transaction_detail.set_category("random")
        if amount is not None:
            self.ew.tap_element(self.transaction_detail.AMOUNT_INPUT)
            self.ew.wait_till_element_is_visible(self.transaction_detail.NUMPAD_CLEAR, 10)
            for i in range(6):
                self.ew.wait_and_tap_element(self.transaction_detail.NUMPAD_CLEAR, 5)
            self.transaction_detail.set_amount(amount)
        if outgoing_wallet is not None:
            if self.transaction_detail.get_wallet("transfer_outgoing") == "Out of Spendee":
                self.transaction_detail.set_wallet(outgoing_wallet, "transfer_outgoing")
        if incoming_wallet is not None:
            if self.transaction_detail.get_wallet("transfer_incoming") == "Out of Spendee":
                self.transaction_detail.set_wallet(incoming_wallet, "transfer_incoming")
        if start_date is not None:
            self.transaction_detail.set_start_date(start_date)
        if note is not None:
            try:
                self.ew.get_element(self.transaction_detail.EXISTING_NOTE).clear()
            except NoSuchElementException:
                pass
            self.transaction_detail.set_note(note)
        if recurrence is not None:
            self.transaction_detail.set_recurrence(recurrence)
        if end_date is not None:
            self.transaction_detail.set_end_date(end_date)
        if reminder is not None:
            self.ew.wait_till_element_is_visible(self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)
            self.ew.swipe_if_element_not_present(self.transaction_detail.REMINDER)
            self.transaction_detail.set_reminder(reminder)
        self.ew.wait_till_element_is_visible(self.transaction_detail.SAVE_TRANSACTION_BUTTON, 5)
예제 #7
0
 def __init__(self, driver):
     self.driver = driver
     self.ew = ElementWrapper(self.driver)
     self.timeline_general = TimelineGeneral(self.driver)
     self.transaction_actions = TransactionActions(self.driver)
     self.transaction_detail = TransactionDetail(self.driver)