def test_manage_photos(self): """ test for manager photos page""" login(self) self.selenium.get('%s%s' % (self.live_server_url, '/manager/galery/photos/')) # header header_title = self.selenium.find_element_by_tag_name("h1") self.assertEqual(header_title.text, "Administration des photos") cards = self.selenium.find_elements_by_class_name('card') self.assertEqual(len(cards), 4) # link for visit the photos page on the site self.selenium.find_element_by_link_text( "Visualiser les photos sur le site").click() wait = WebDriverWait(self.selenium, 10) wait.until(EC.number_of_windows_to_be(2)) default_handle = self.selenium.current_window_handle self.selenium.switch_to_window(self.selenium.window_handles[1]) header_title = self.selenium.find_element_by_tag_name("h1") self.assertEqual(header_title.text, "Photos") self.selenium.close() self.selenium.switch_to_window(default_handle) # add video with form self.selenium.find_element_by_link_text('Ajouter une photo').click() self.selenium.find_element_by_id("id_image").send_keys("".join( [BASE_DIR, "/uploads/tests/photos/photo1.jpg"])) self.selenium.find_element_by_id("id_title").send_keys( "test manage add title") self.selenium.find_element_by_id('btn-form-add-mod').click() time.sleep(30) card_titles = self.selenium.find_elements_by_tag_name("h6") self.assertEqual("test manage add title", card_titles[0].text) # update video with form update_links = self.selenium.find_elements_by_link_text( "Modifier le titre") update_links[1].click() self.selenium.find_element_by_id("id_title").clear() self.selenium.find_element_by_id("id_title").send_keys( "test manage update title") self.selenium.find_element_by_id('btn-form-add-mod').click() time.sleep(10) card_titles = self.selenium.find_elements_by_tag_name("h6") self.assertEqual("test manage update title", card_titles[0].text) # delete video self.assertEqual("test manage add title", card_titles[1].text) delete_links = self.selenium.find_elements_by_link_text("Supprimer") delete_links[1].click() alert = self.selenium.switch_to_alert() alert.accept() wait = WebDriverWait(self.selenium, 10) wait.until(EC.alert_is_present()) alert = self.selenium.switch_to_alert() alert.accept() time.sleep(10) card_titles = self.selenium.find_elements_by_tag_name("h6") card_title_texts = [] for card_title in card_titles: card_title_texts.append(card_title.text) self.assertNotIn("test manage add title", card_title_texts) logout(self)
def test_manage_actus(self): """ test for manager messages page""" login(self) self.selenium.get('%s%s' % (self.live_server_url, '/manager/message/')) # header header_title = self.selenium.find_element_by_tag_name("h1") self.assertEqual(header_title.text, "Boîte à messages") messages = self.selenium.find_elements_by_tag_name('tr') self.assertEqual((len(messages) - 1), 3) # display message in main msg_subjects = self.selenium.find_elements_by_css_selector("td a") msg_subjects[3].click() wait = WebDriverWait(self.selenium, 10) wait.until(EC.presence_of_element_located((By.TAG_NAME, "main"))) name = self.selenium.find_element_by_id('contact_name') email = self.selenium.find_element_by_id('contact_email') date = self.selenium.find_element_by_id('date') subject = self.selenium.find_element_by_id('subject') content = self.selenium.find_element_by_css_selector('#content p') self.assertEqual(name.text, "the boss") self.assertEqual(email.text, "*****@*****.**") self.assertEqual(date.text, "28/01/2019 à 10:58") self.assertEqual(subject.text, "Réunion générale") self.assertEqual(content.text, "Réunion à 17h") # close message self.selenium.find_element_by_class_name("btn-dark").click() wait = WebDriverWait(self.selenium, 10) wait.until(EC.presence_of_element_located((By.CLASS_NAME, "fa-check"))) # delete message del_links = self.selenium.find_elements_by_class_name('fa-trash-o') del_links[2].click() wait.until(EC.alert_is_present()) alert = self.selenium.switch_to_alert() alert.accept() wait.until(EC.alert_is_present()) alert = self.selenium.switch_to_alert() alert.accept() time.sleep(10) messages = self.selenium.find_elements_by_tag_name('tr') self.assertEqual((len(messages) - 1), 2) logout(self)
def test_manage_galery(self): """ test for manager galery page""" login(self) # header self.selenium.get('%s%s' % (self.live_server_url, '/manager/galery/')) header_title = self.selenium.find_element_by_tag_name("h1") self.assertEqual(header_title.text, "Administration de la galerie") # link for visit the galery page on the site self.selenium.find_element_by_link_text( "Visualiser la galerie sur le site").click() wait = WebDriverWait(self.selenium, 10) wait.until(EC.number_of_windows_to_be(2)) default_handle = self.selenium.current_window_handle self.selenium.switch_to_window(self.selenium.window_handles[1]) header_title = self.selenium.find_element_by_tag_name("h1") self.assertEqual(header_title.text, "Galerie") self.selenium.close() self.selenium.switch_to_window(default_handle) # link for admin photo self.selenium.find_element_by_link_text( "Adminstration des photos").click() wait.until( EC.presence_of_element_located((By.ID, "header_manager_photos"))) header_title = self.selenium.find_element_by_tag_name("h1") self.assertEqual(header_title.text, "Administration des photos") # link for admin video self.selenium.back() wait.until( EC.presence_of_element_located((By.ID, "header_manager_galery"))) self.selenium.find_element_by_link_text( "Adminstration des vidéos").click() wait.until( EC.presence_of_element_located((By.ID, "header_manager_videos"))) header_title = self.selenium.find_element_by_tag_name("h1") self.assertEqual(header_title.text, "Administration des vidéos") logout(self)