def test_follow_new_entry_link(self): """ Click on the 'New Entry' button in the toolbar, verify that it leads to entry page. """ self.page.click_new_entry_button() self.page = GeopostEntryPage(self.driver) self.assertTrue(self.page.verify_path())
def setUp(self): """ Make driver, page, sign in. """ with open('/etc/zachsite_test_creds.txt') as f: testCreds = f.readlines() self.driver = webdriver.Firefox() self.driver.get(LoginPage.URL) self.page = LoginPage(self.driver) self.page.enter_username(testCreds[0].strip()) self.page.enter_password(testCreds[1].strip()) self.page.login() self.driver.get(GeopostHomePage.URL) self.page = GeopostHomePage(self.driver)
def test_create_edit_delete(self): """ Create a point, edit it, delete it. """ # read parameter file with open(SCRIPT_DIR + '/data_edit_entry_valid.csv') as f: testData = f.readlines() # run subtests for paramList in testData: params = paramList.split(',') with self.subTest(params=params): # reload page for each subtest self.driver.get(GeopostEntryPage.URL) self.page = GeopostEntryPage(self.driver) # make new entry self.page.toggle_draw() self.page.draw_point() self.page.enter_title(params[0]) self.page.enter_body(params[1]) self.page.choose_photo(SCRIPT_DIR + params[2].strip()) self.page.submit_form() # verify that entry was created successfully self.page = GeopostHomePage(self.driver) self.assertTrue(self.page.verify_path(time=12)) self.assertTrue( self.page.verify_entry_exists_by_title(params[0]) ) # edit the entry self.page.edit_by_title(params[0]) self.page = GeopostEntryPage(self.driver) self.assertTrue(self.page.verify_path(time=8)) self.assertEqual(self.page.get_title(), params[0]) self.assertEqual(self.page.get_body(), params[1]) self.page.draw_point() self.page.enter_title(params[3]) self.page.enter_body(params[4]) self.page.choose_photo(SCRIPT_DIR + params[5].strip()) self.page.submit_form() # verify that entry was edited successfully self.page = GeopostHomePage(self.driver) self.assertTrue(self.page.verify_path(time=8)) self.assertTrue( self.page.verify_entry_exists_by_title(params[3]) ) # Delete the newly created post self.page.delete_by_title(params[3]) # Verify that the delete worked self.assertFalse( self.page.verify_entry_exists_by_title(params[3]) )
def tearDown(self): """ Close driver. """ self.driver.get(LogoutPage.URL) self.page = LogoutPage(self.driver) self.assertTrue(self.page.verify_logged_out()) self.driver.close()
class HomeAuthedTests(HomeAnonymousTests): """ Methods to test app home page as authed user. """ def setUp(self): """ Make driver, page, sign in. """ with open('/etc/zachsite_test_creds.txt') as f: testCreds = f.readlines() self.driver = webdriver.Firefox() self.driver.get(LoginPage.URL) self.page = LoginPage(self.driver) self.page.enter_username(testCreds[0].strip()) self.page.enter_password(testCreds[1].strip()) self.page.login() self.driver.get(GeopostHomePage.URL) self.page = GeopostHomePage(self.driver) def tearDown(self): """ Close driver. """ self.driver.get(LogoutPage.URL) self.page = LogoutPage(self.driver) self.assertTrue(self.page.verify_logged_out()) self.driver.close() def test_auth_elements(self): """ Override: Test that the server included the toolbar and edit/delete buttons for the authenticated user. """ self.assertTrue(self.page.verify_toolbar_present()) self.assertTrue(self.page.verify_edit_button_present()) self.assertTrue(self.page.verify_delete_button_present()) def test_toolbar_open_and_close(self): """ Make sure the toolbar opens and closes when toggled. """ self.assertTrue(self.page.verify_toolbar_displayed()) self.page.toggle_toolbar() self.assertTrue(self.page.verify_toolbar_not_displayed()) self.page.toggle_toolbar() self.assertTrue(self.page.verify_toolbar_displayed()) def test_follow_new_entry_link(self): """ Click on the 'New Entry' button in the toolbar, verify that it leads to entry page. """ self.page.click_new_entry_button() self.page = GeopostEntryPage(self.driver) self.assertTrue(self.page.verify_path())