def list_has_number_of_entries(context, expected_count): elp = ExpenseListPage(context.browser) ui_entires = elp.get_number_of_visible_rows() assert int( expected_count ) == ui_entires, 'Incorrect number of entires visible on ui : ' + str( ui_entires)
def filter_has_value(context, has_or_not, payer_name): payer_name = payer_name if payer_name != 'n/a' else '' elp = ExpenseListPage(context.browser) if has_or_not == 'has': assert elp.select_dropdown_has_value( 'filter', payer_name), 'Filter does not have option: ' + payer_name + '"' else: assert not elp.select_dropdown_has_value( 'filter', payer_name), 'Filter has option: ' + payer_name + '"'
def add_expense_payer_has_value(context, has_or_not, payer_name): payer_name = payer_name if payer_name != 'n/a' else '' elp = ExpenseListPage(context.browser) if has_or_not == 'has': assert elp.select_dropdown_has_value( 'add exp payer', payer_name ), 'New expense Payer dropdown does not have option: "' + payer_name + '"' else: assert not elp.select_dropdown_has_value( 'add exp payer', payer_name ), 'New expense Payer dropdown has option: "' + payer_name + '"'
def expense_list_has_payment(context, has_or_not, title, payer, amount): title = title if title != 'n/a' else '' payer = payer if payer != 'n/a' else '' amount = amount if amount != 'n/a' else '' elp = ExpenseListPage(context.browser) if has_or_not == 'has': assert elp.list_row_is_present([ title, payer, amount ]), 'Row with ' + str([title, payer, amount]) + ' is not present' else: assert not elp.list_row_is_present([ title, payer, amount ]), 'Row with ' + str([title, payer, amount]) + ' is present'
def run(self, testData): self.driver.get('http://localhost:3000') expenseList = ExpenseListPage(self.driver) base_sum = converse_to_float(expenseList.get_sum_of_expenses()) expenseList.add_new_payer(testData[1]) expenseList.add_new_expense(testData) final_sum = expenseList.get_sum_of_expenses() assert converse_to_float(final_sum) == base_sum + converse_to_float( testData[2])
def validate_incorrect_scenarion(self, testData): expenseList = ExpenseListPage(self.driver) expenseList.open_select_dropdown('add exp payer') assert not expenseList.select_dropdown_has_value( 'add exp payer', testData ), 'Incorrect payer added to Add Expense payer dropdown: "' + testData + '"' expenseList.open_select_dropdown('filter') assert not expenseList.select_dropdown_has_value( 'filter', testData ), 'Incorrect payer added to Expense Filter dropdown: "' + testData + '"'
def validate_correct_scenario(self, testData): expenseList = ExpenseListPage(self.driver) expenseList.open_select_dropdown('add exp payer') assert expenseList.select_dropdown_has_value( 'add exp payer', testData), 'Correct Expense payer not added: ' + testData expenseList.open_select_dropdown('filter') assert expenseList.select_dropdown_has_value( 'filter', testData ), 'Correct Expense Expense Filter payer not added: ' + testData
def run(self, testData): self.driver.get('http://localhost:3000') expenseList = ExpenseListPage(self.driver) current_sum = expenseList.get_sum_of_expenses() expenseList.add_new_expense(testData) assert expenseList.get_sum_of_expenses( ) == current_sum + converse_to_float(testData[2])
def validate_incorrect_expense(self, testData): expenseList = ExpenseListPage(self.driver) assert not expenseList.list_row_is_present(testData[0]), 'Invalid expense was added to list: ' + str(testData[0]) assert expenseList.get_number_of_visible_rows() == testData[1], 'New expense was added'
def validate_correct_expense(self, testData): expenseList = ExpenseListPage(self.driver) assert expenseList.list_row_is_present(testData), 'Correct expense was not added to list: ' + str(testData)
def perform_filtering(context, payer): elp = ExpenseListPage(context.browser) elp.open_select_dropdown('filter') elp.select_value_in_select_dropdown('filter', payer) # for closing elp.open_select_dropdown('filter')
def run(self, testData): self.driver.get('http://localhost:3000') expenseList = ExpenseListPage(self.driver) assert expenseList.get_sum_of_expenses() == testData
def run(self, testData): self.driver.get('http://localhost:3000') expenseList = ExpenseListPage(self.driver) expenseList.add_new_payer(testData)
def add_expense(context, title, payer, amount): title = title if title != 'n/a' else '' payer = payer if payer != 'n/a' else '' amount = amount if amount != 'n/a' else '' elp = ExpenseListPage(context.browser) elp.add_new_expense([title, payer, amount])
def expense_page_is_loaded(context): ExpenseListPage(context.browser)
def add_new_payer(context, payer_name): payer_name = payer_name if payer_name != 'n/a' else '' elp = ExpenseListPage(context.browser) elp.add_new_payer(payer_name)
def expense_sum_is_equal_to(context, expected_sum): elp = ExpenseListPage(context.browser) assert converse_to_float(expected_sum) == elp.get_sum_of_expenses()
def run(self, testData): self.driver.get('http://localhost:3000') expenseList = ExpenseListPage(self.driver) assert expenseList.list_row_is_present(testData)
def run(self, testData): self.driver.get('http://localhost:3000') expenseList = ExpenseListPage(self.driver) expenseList.open_select_dropdown('filter') f_text = testData[0] exp_rows = testData[1] expenseList.select_value_in_select_dropdown('filter', f_text) assert expenseList.get_select_dropdown_value( 'filter') == f_text, expenseList.get_select_dropdown_value( 'filter') + '!=' + f_text assert expenseList.get_number_of_visible_rows() == len(exp_rows), str( expenseList.get_number_of_visible_rows()) + '!=' + str( len(exp_rows)) for exp_row in exp_rows: assert expenseList.list_row_is_present(exp_row)