def test_people_import(self): """ Imports users via xls file. We assume that the users in the file didn't exist and they must be successfully created. """ driver = self.driver login(driver, self.portal, username=testing.MANAGER, password=testing.PASSWORD) open(driver, self.portal.absolute_url() + "/people/import") fileUpload = driver.find_element_by_name("form.widgets.file") filename = testing.asset_path("covalent_batch.xls") fileUpload.send_keys(filename) driver.find_element_by_id("form-buttons-save").click() trs = self.find_elements(By.CSS_SELECTOR, "#content tbody tr") table = [[td.text for td in tr.find_elements_by_tag_name('td')] for tr in trs] self.assertEquals(table, [ [u'Test User', u't.user', u'*****@*****.**'], [u'Estt Seru', u'estt_seru', u'*****@*****.**'], [u'Stte Erus', u'stte127', u'*****@*****.**'], ]) driver.find_element_by_name("confirm").click() open(driver, self.portal.absolute_url() + "/people/folder_contents") pending_members = [x.text for x in self.find_elements(By.CSS_SELECTOR, 'a.state-pending')] for member in table: self.assertIn(member[0], pending_members)
def test_ws_conversation_file_upload_and_metadata(self): """ Uploads a file to an existing entry """ fileTitle = "New file" driver = self.driver login(driver, self.portal, username='******', password='******') open(driver, self.portal.absolute_url() + "/workspaces/workspace-1/conversation") self.assertFalse(self.is_element_present(By.CSS_SELECTOR, "#fileMetaDataHelperMessage a", wait=1)) self.find_elements(By.CSS_SELECTOR, "#column-content.js-ready #entries > .entry a.conversation-edit-entry")[0].click() WebDriverWait(driver, 20).until(lambda l: driver.find_element_by_id("form.widgets.text_ifr")) driver.find_element_by_css_selector(".entry-edit form.js-ready") fileUpload = driver.find_element_by_name("file") filename = testing.asset_path("example_text_file.txt") fileUpload.send_keys(filename) driver.find_element_by_id("form-buttons-save").click() # the following seems to take a little longer sometimes fileTitleInput = self.find_element(By.ID, "form-widgets-IBasic-title", wait=30) fileTitleInput.clear() fileTitleInput.send_keys(fileTitle) driver.find_element_by_partial_link_text("Publication").click() authorInput = self.find_element(By.ID, "form-widgets-IRichMetaData-rmAuthor", wait=0) authorInput.send_keys("Author name") tagsInput = self.find_element(By.ID, "form_widgets_IRichMetaData_rmTags_select_chzn", wait=0) tagsInput.click() tagElement = self.find_element(By.CSS_SELECTOR, "#form_widgets_IRichMetaData_rmTags_select_chzn .chzn-results li", wait=0) tagElement.click() fileMetaDataSaveButton = self.find_element(By.ID, "richfile-form-buttons-save", wait=0) fileMetaDataSaveButton.click() WebDriverWait(driver, 20).until_not(lambda l: self.is_element_present(By.CSS_SELECTOR, ".exposeMask", wait=0)) self.assertElementWithText(By.CSS_SELECTOR, "#entries .entry a", fileTitle) self.assertFalse(self.is_element_present(By.CSS_SELECTOR, "#fileMetaDataHelperMessage a", wait=1))
def _test_ws_create_with_files(self): """ Uploads files to a workspace """ wsName = "New workspace" fileTitle = "New file" driver = self.driver login(driver, self.portal, username=testing.MANAGER, password=testing.PASSWORD) open(driver, self.portal.absolute_url() + "/challenges/challenge-1") self.find_element_by_text("Create Workspace").click() titleInput = driver.find_element_by_id("form-widgets-title") titleInput.clear() titleInput.send_keys(wsName) self.find_element_with_text("Material").click() fileUpload = driver.find_element_by_name("file") filename = testing.asset_path("example_text_file.txt") fileUpload.send_keys(filename) WebDriverWait(driver, 20).until(lambda l: self.is_element_present(By.ID, "fileMetadataOverlay", wait=0)) fileTitleInput = self.find_element(By.ID, "form-widgets-IBasic-title") fileTitleInput.clear() fileTitleInput.send_keys(fileTitle) driver.find_element_by_partial_link_text("Publication").click() authorInput = self.find_element(By.ID, "form-widgets-IRichMetaData-rmAuthor", wait=0) authorInput.send_keys("Author name") tagsInput = self.find_element(By.ID, "form_widgets_IRichMetaData_rmTags_select_chzn", wait=0) tagsInput.click() tagElement = self.find_element(By.CSS_SELECTOR, "#form_widgets_IRichMetaData_rmTags_select_chzn .chzn-results li", wait=0) tagElement.click() fileMetaDataSaveButton = self.find_element(By.ID, "richfile-form-buttons-save", wait=0) fileMetaDataSaveButton.click() WebDriverWait(driver, 20).until(lambda l: self.is_element_present(By.CSS_SELECTOR, "#file-list-wrapper .related-filetypes", wait=0)) self.assertElementWithText(By.CSS_SELECTOR, "#file-list-wrapper dt", "Publication", wait=0) self.assertElementWithText(By.CSS_SELECTOR, "#file-list-wrapper a", fileTitle, wait=0) self.find_element(By.CSS_SELECTOR, "input[value='Save']", wait=0).click() elementsWithWsName = self.find_elements_with_text(wsName) elementVisible = False for element in elementsWithWsName: # Check that there is one element that contains the workspace name as text, and it's visible (this is supposed to be the "h1" title) elementVisible = elementVisible or element.is_displayed() assert elementVisible portalMessage = self.find_element_with_text("Changes saved") assert portalMessage.is_displayed()