Skip to content

Commit

Permalink
issue #178 - another attempt at working around all the intermittent T…
Browse files Browse the repository at this point in the history
…ravisCI errors when clicking a JS link that triggers a modal
  • Loading branch information
jantman committed Mar 12, 2018
1 parent eba6f55 commit 2868a80
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ def test_06_add_interest(self, selenium, base_url):
'//a[text()="manually input the interest charge from your '
'last statement"]'
)
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add Manual Interest Charge for Account 4'
frm_id = selenium.find_element_by_id('payoff_acct_frm_id')
Expand Down
18 changes: 6 additions & 12 deletions biweeklybudget/tests/acceptance/flaskapp/views/test_fuel.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ def test_01_vehicle_populate_modal(self, base_url, selenium):
self.get(selenium, base_url + '/fuel')
link = selenium.find_element_by_xpath('//a[text()="Veh1"]')
self.wait_until_clickable(selenium, '//a[text()="Veh1"]', by='xpath')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Edit Vehicle 1'
assert selenium.find_element_by_id('vehicle_frm_id').get_attribute(
Expand All @@ -288,8 +287,7 @@ def test_02_vehicle_edit_modal_inactive(self, base_url, selenium):
self.wait_until_clickable(
selenium, '//a[text()="Veh3Inactive"]', by='xpath'
)
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Edit Vehicle 3'
assert selenium.find_element_by_id('vehicle_frm_id').get_attribute(
Expand Down Expand Up @@ -350,8 +348,7 @@ def test_04_vehicle_modal_add(self, base_url, selenium):
self.get(selenium, base_url + '/fuel')
link = selenium.find_element_by_id('btn-add-vehicle')
self.wait_until_clickable(selenium, 'btn-add-vehicle')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add New Vehicle'
name = selenium.find_element_by_id('vehicle_frm_name')
Expand Down Expand Up @@ -417,8 +414,7 @@ def test_11_fuel_populate_modal(self, base_url, selenium):
self.get(selenium, base_url + '/fuel')
link = selenium.find_element_by_id('btn-add-fuel')
self.wait_until_clickable(selenium, 'btn-add-fuel')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add Fuel Fill'
veh_sel = Select(selenium.find_element_by_id('fuel_frm_vehicle'))
Expand Down Expand Up @@ -488,8 +484,7 @@ def test_12_fuel_add_no_trans(self, base_url, selenium):
self.get(selenium, base_url + '/fuel')
link = selenium.find_element_by_id('btn-add-fuel')
self.wait_until_clickable(selenium, 'btn-add-fuel')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add Fuel Fill'
veh_sel = Select(selenium.find_element_by_id('fuel_frm_vehicle'))
Expand Down Expand Up @@ -591,8 +586,7 @@ def test_14_fuel_add_with_trans(self, base_url, selenium):
self.get(selenium, base_url + '/fuel')
link = selenium.find_element_by_id('btn-add-fuel')
self.wait_until_clickable(selenium, 'btn-add-fuel')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add Fuel Fill'
veh_sel = Select(selenium.find_element_by_id('fuel_frm_vehicle'))
Expand Down
6 changes: 2 additions & 4 deletions biweeklybudget/tests/acceptance/flaskapp/views/test_ofx.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ def get_page(self, base_url, selenium):

def test_modal_on_click(self, selenium):
link = selenium.find_element_by_xpath('//a[text()="T1"]')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'OFXTransaction Account=3 FITID=T1'
texts = self.tbody2textlist(body)
Expand Down Expand Up @@ -385,8 +384,7 @@ def test_1_modal(self, base_url, selenium):
self.get(selenium, base_url + '/transactions')
link = selenium.find_element_by_xpath(
'//a[@href="javascript:txnReconcileModal(1)"]')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Transaction Reconcile 1'
dl = body.find_element_by_tag_name('dl')
Expand Down
45 changes: 15 additions & 30 deletions biweeklybudget/tests/acceptance/flaskapp/views/test_payperiods.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,7 @@ def test_06_add_trans_button(self, base_url, selenium, testdb):
PAY_PERIOD_START_DATE.strftime('%Y-%m-%d')
)
btn = selenium.find_element_by_id('btn-add-txn')
btn.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, btn)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add New Transaction'

Expand Down Expand Up @@ -1115,8 +1114,7 @@ def test_08_transaction_modal(self, base_url, selenium, testdb):
PAY_PERIOD_START_DATE.strftime('%Y-%m-%d')
)
link = selenium.find_element_by_xpath('//a[text()="T1foo (6)"]')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Edit Transaction 6'
assert body.find_element_by_id(
Expand Down Expand Up @@ -1167,8 +1165,7 @@ def test_09_transaction_modal_edit(self, base_url, selenium, testdb):
PAY_PERIOD_START_DATE.strftime('%Y-%m-%d')
)
link = selenium.find_element_by_xpath('//a[text()="T1foo (6)"]')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Edit Transaction 6'
assert body.find_element_by_id(
Expand Down Expand Up @@ -1229,8 +1226,7 @@ def test_12_sched_trans_modal(self, base_url, selenium):
)
link = selenium.find_element_by_xpath(
'//a[text()="ST7 per_period (7)"]')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Edit Scheduled Transaction 7'
assert body.find_element_by_id(
Expand Down Expand Up @@ -1262,8 +1258,7 @@ def test_13_sched_trans_modal_edit(self, base_url, selenium):
)
link = selenium.find_element_by_xpath(
'//a[text()="ST7 per_period (7)"]')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
desc = body.find_element_by_id('sched_frm_description')
desc.send_keys('edited')
Expand Down Expand Up @@ -1306,8 +1301,7 @@ def test_20_issue152_active_budget(self, base_url, selenium):
PAY_PERIOD_START_DATE.strftime('%Y-%m-%d')
)
btn = selenium.find_element_by_id('btn-add-txn')
btn.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, btn)
self.assert_modal_displayed(modal, title, body)
dt_text = body.find_element_by_id('trans_frm_date')
dt_text.clear()
Expand Down Expand Up @@ -1443,8 +1437,7 @@ def test_24_issue152_attempt_add_inactive_budget(self, base_url, selenium):
PAY_PERIOD_START_DATE.strftime('%Y-%m-%d')
)
btn = selenium.find_element_by_id('btn-add-txn')
btn.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, btn)
self.assert_modal_displayed(modal, title, body)
dt_text = body.find_element_by_id('trans_frm_date')
dt_text.clear()
Expand Down Expand Up @@ -1547,8 +1540,7 @@ def test_31_issue152_edit_inactive(self, base_url, selenium):
link = selenium.find_element_by_xpath(
'//a[text()="issue152regression3 (10)"]'
)
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Edit Transaction 10'
assert body.find_element_by_id(
Expand Down Expand Up @@ -1782,8 +1774,7 @@ def test_04_make_trans_modal_num_per(self, base_url, selenium, testdb):
link = selenium.find_elements_by_xpath(
'//a[@href="javascript:schedToTransModal(7, \'%s\');"]'
'' % pp.start_date.strftime('%Y-%m-%d'))[0]
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Scheduled Transaction 7 to Transaction'
assert body.find_element_by_id(
Expand Down Expand Up @@ -1815,8 +1806,7 @@ def test_05_modal_schedtrans_to_trans(self, base_url, selenium, testdb):
link = selenium.find_elements_by_xpath(
'//a[@href="javascript:schedToTransModal(7, \'%s\');"]'
'' % pp.start_date.strftime('%Y-%m-%d'))[0]
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
body.find_element_by_id('schedtotrans_frm_date').clear()
body.find_element_by_id('schedtotrans_frm_date').send_keys(
Expand Down Expand Up @@ -2168,8 +2158,7 @@ def test_08_budget_transfer(self, base_url, selenium, testdb):
PAY_PERIOD_START_DATE.strftime('%Y-%m-%d')
)
link = selenium.find_element_by_id('btn-budg-txfr-periodic')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Budget Transfer'
assert body.find_element_by_id(
Expand Down Expand Up @@ -2487,8 +2476,7 @@ def test_17_budget_transfer_modal_date_curr_period(
PAY_PERIOD_START_DATE.strftime('%Y-%m-%d')
)
link = selenium.find_element_by_id('btn-budg-txfr-periodic')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Budget Transfer'
assert body.find_element_by_id(
Expand All @@ -2504,8 +2492,7 @@ def test_18_budget_transfer_modal_date_prev_period(
date(2017, 6, 23).strftime('%Y-%m-%d')
)
link = selenium.find_element_by_id('btn-budg-txfr-periodic')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Budget Transfer'
assert body.find_element_by_id(
Expand All @@ -2520,8 +2507,7 @@ def test_19_budget_transfer_modal_date_next_period(
date(2017, 8, 18).strftime('%Y-%m-%d')
)
link = selenium.find_element_by_id('btn-budg-txfr-periodic')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Budget Transfer'
assert body.find_element_by_id(
Expand Down Expand Up @@ -2823,8 +2809,7 @@ def test_08_budget_transfer(self, base_url, selenium, testdb):
link = selenium.find_elements_by_xpath(
'//a[@href="javascript:skipSchedTransModal(8, \'%s\');"]'
'' % pp.start_date.strftime('%Y-%m-%d'))[0]
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Skip Scheduled Transaction 8 in period %s' \
% pp.start_date.strftime('%Y-%m-%d')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ def test_03_populate_modal(self, base_url, selenium):
editlink = selenium.find_element_by_xpath(
'//a[@onclick="bomItemModal(3)"]'
)
editlink.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, editlink)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Edit BoM Item 3'
id = body.find_element_by_id('bom_frm_id')
Expand All @@ -539,8 +538,7 @@ def test_04_edit_item(self, base_url, selenium):
editlink = selenium.find_element_by_xpath(
'//a[@onclick="bomItemModal(3)"]'
)
editlink.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, editlink)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Edit BoM Item 3'
id = body.find_element_by_id('bom_frm_id')
Expand Down Expand Up @@ -664,8 +662,7 @@ def test_05_verify_db(self, testdb):
def test_06_add_item(self, base_url, selenium):
self.get(selenium, base_url + '/projects/1')
editlink = selenium.find_element_by_id('btn_add_item')
editlink.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, editlink)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add New BoM Item'
id = body.find_element_by_id('bom_frm_id')
Expand Down
17 changes: 7 additions & 10 deletions biweeklybudget/tests/acceptance/flaskapp/views/test_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,7 @@ def test_07_edit(self, base_url, selenium):
self.baseurl = base_url
self.get(selenium, base_url + '/reconcile')
link = selenium.find_element_by_xpath('//a[text()="Trans 1"]')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Edit Transaction 1'
assert body.find_element_by_id(
Expand Down Expand Up @@ -1659,9 +1658,8 @@ def test_08_trans_from_ofx(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
ofxdiv = selenium.find_element_by_id('ofx-2-OFX2')
link = ofxdiv.find_element_by_xpath('//a[text()="(make trans)"]')
link.click()
# test the modal population
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add Transaction for OFX (2, OFX2)'
assert body.find_element_by_id(
Expand Down Expand Up @@ -1851,9 +1849,8 @@ def test_33_ignore_ofx(self, base_url, selenium):
self.get(selenium, base_url + '/reconcile')
ofxdiv = selenium.find_element_by_id('ofx-2-OFX31')
link = ofxdiv.find_element_by_xpath('//a[text()="(ignore)"]')
link.click()
# test the modal population
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Ignore OFXTransaction (2, "OFX31")'
assert body.find_element_by_id(
Expand Down Expand Up @@ -1970,9 +1967,8 @@ def test_36_ignore_and_unignore_ofx(self, base_url, selenium):
# ignore
ofxdiv = selenium.find_element_by_id('ofx-2-OFX30')
link = ofxdiv.find_element_by_xpath('//a[text()="(ignore)"]')
link.click()
# test the modal population
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Ignore OFXTransaction (2, "OFX30")'
assert body.find_element_by_id(
Expand Down Expand Up @@ -2286,8 +2282,9 @@ def test_09_reconcile_unreconcile_noOFX(self, base_url, selenium):
)
assert self.get_reconciled(selenium) == {}
# reconcile as noOFX
trans.find_element_by_link_text('(no OFX)').click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(
selenium, trans.find_element_by_link_text('(no OFX)')
)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Reconcile Transaction 3 Without OFX'
assert body.find_element_by_id(
Expand Down
15 changes: 5 additions & 10 deletions biweeklybudget/tests/acceptance/flaskapp/views/test_scheduled.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,7 @@ def test_1_modal_on_click(self, base_url, selenium):
self.baseurl = base_url
self.get(selenium, base_url + '/scheduled')
link = selenium.find_element_by_xpath('//a[text()="ST3"]')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Edit Scheduled Transaction 3'
assert body.find_element_by_id(
Expand Down Expand Up @@ -471,8 +470,7 @@ def test_10_add_date_modal_on_click(self, base_url, selenium):
self.baseurl = base_url
self.get(selenium, base_url + '/scheduled')
link = selenium.find_element_by_id('btn_add_sched')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add New Scheduled Transaction'
desc = body.find_element_by_id('sched_frm_description')
Expand Down Expand Up @@ -538,8 +536,7 @@ def test_21_add_monthly_modal_on_click(self, base_url, selenium):
self.baseurl = base_url
self.get(selenium, base_url + '/scheduled')
link = selenium.find_element_by_id('btn_add_sched')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add New Scheduled Transaction'
desc = body.find_element_by_id('sched_frm_description')
Expand Down Expand Up @@ -594,8 +591,7 @@ def test_31_add_per_period_modal_on_click(self, base_url, selenium):
self.baseurl = base_url
self.get(selenium, base_url + '/scheduled')
link = selenium.find_element_by_id('btn_add_sched')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add New Scheduled Transaction'
desc = body.find_element_by_id('sched_frm_description')
Expand Down Expand Up @@ -650,8 +646,7 @@ def test_41_add_income_modal_on_click(self, base_url, selenium):
self.baseurl = base_url
self.get(selenium, base_url + '/scheduled')
link = selenium.find_element_by_id('btn_add_sched')
link.click()
modal, title, body = self.get_modal_parts(selenium)
modal, title, body = self.try_click_and_get_modal(selenium, link)
self.assert_modal_displayed(modal, title, body)
assert title.text == 'Add New Scheduled Transaction'
desc = body.find_element_by_id('sched_frm_description')
Expand Down
Loading

0 comments on commit 2868a80

Please sign in to comment.