def _test_can_access(self, page, user=None, can_access=True): _url = page.driver.current_url _title = page.title _id = page.id page.close() if user: page = LoginPage().log_in(user) page.driver.get(_url) if can_access: page = ProjectPage(driver=page.driver) self.assertEqual(page.title, _title) else: with self.assertRaises(PageException): page = ProjectPage(driver=page.driver) self.assertNotEqual(page.title, _title) page.close() else: if can_access: page = NodePage(url=_url) page.close() else: with self.assertRaises(PageException): ProjectPage(id=_id)
def test_move_quickfile_to_new_project(self, driver, session, my_quickfiles): my_quickfiles.loading_indicator.here_then_gone() file_name = driver.find_element( By.CSS_SELECTOR, '[data-test-file-icon-and-name]' ).text my_quickfiles.files[0].click() my_quickfiles.move_button.click() # verify move modal assert my_quickfiles.generic_modal.present() assert my_quickfiles.generic_modal.text == 'Move file to project' assert my_quickfiles.move_create_new_project_button.present() assert my_quickfiles.move_existing_project_button.present() my_quickfiles.move_create_new_project_button.click() new_project_tile = 'OSF Selenium Test Quickfile Move' my_quickfiles.create_project_modal.title_input.send_keys(new_project_tile) my_quickfiles.create_project_modal.create_project_button.click() my_quickfiles.project_created_modal.go_to_project_href_link.click() project_page = ProjectPage(driver, verify=True) assert project_page.title.text == new_project_tile # Capture guid for project so we can delete it later match = re.search(r'osf\.io/([a-z0-9]{5})', driver.current_url) project_guid = match.group(1) # Verify that Quick File is listed in Project Files Widget project_page.file_widget.loading_indicator.here_then_gone() assert project_page.file_widget.component_and_file_titles[3].text == file_name # Go back to My Quick Files page and verify that file is no longer listed there my_quickfiles.goto() my_quickfiles.loading_indicator.here_then_gone() assert len(my_quickfiles.files) == 0 # Cleanup - delete the new project osf_api.delete_project(session, project_guid, None)
def test_meeting_detail(self, meeting_detail_page, driver): assert meeting_detail_page.entry_download_button.present() entry_title = meeting_detail_page.first_entry_link.text meeting_detail_page.first_entry_link.click() project_page = ProjectPage(driver, verify=True) assert entry_title.strip() == project_page.title.text
def test_create_new_project(self, driver, my_projects_page, fake): title = fake.sentence(nb_words=4) my_projects_page.create_project_button.click() create_project_modal = my_projects_page.create_project_modal create_project_modal.title_input.clear() create_project_modal.title_input.send_keys(title) create_project_modal.create_project_button.click() my_projects_page.project_created_modal.go_to_project_href_link.click() project_page = ProjectPage(driver, verify=True) assert project_page.title.text == title, 'Project title incorrect.'
def test_create_project(self, driver, dashboard_page): title = 'New Project' dashboard_page.create_project_button.click() create_project_modal = dashboard_page.create_project_modal create_project_modal.title_input.clear() create_project_modal.title_input.send_keys(title) create_project_modal.create_project_button.click() dashboard_page.project_created_modal.go_to_project_href_link.click() project_page = ProjectPage(driver, verify=True) assert project_page.title.text == title, 'Project title incorrect.'
def node(self, node_id, parent_project=None): # TODO: rename "goto_node()" from pages.project import ProjectPage self.driver.get( '{}/project/{}/'.format( config.osf_home, '{}/node/{}'.format( parent_project, node_id ) if parent_project else node_id, ) ) return ProjectPage(driver=self.driver)
def test_meeting_detail(self, meeting_detail_page, driver): assert meeting_detail_page.entry_download_button.present() entry_title = meeting_detail_page.first_entry_link.text # Need to scroll down since the first entry link is obscured by the Dev mode warning in staging environments # and need to use second project entry to scroll to since scrolling to first entry sometimes still leaves it # partially obscured in some environments (stage 1). WebDriverWait(driver, 5).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, 'li.list-group-item:nth-child(2)'))) second_entry = driver.find_element_by_css_selector( 'li.list-group-item:nth-child(2) > div:nth-child(2)') meeting_detail_page.scroll_into_view(second_entry) meeting_detail_page.first_entry_link.click() project_page = ProjectPage(driver, verify=True) assert entry_title.strip() == project_page.title.text
def test_create_new_project(self, driver, session, my_projects_page, fake): title = fake.sentence(nb_words=4) my_projects_page.create_project_button.click() create_project_modal = my_projects_page.create_project_modal create_project_modal.title_input.clear() create_project_modal.title_input.send_keys(title) create_project_modal.create_project_button.click() my_projects_page.project_created_modal.keep_working_here_button.click() # Wait until modal is gone WebDriverWait(driver, 5).until(EC.invisibility_of_element_located((By.CSS_SELECTOR, 'button[data-dismiss="modal"]'))) my_projects_page.goto() guid = my_projects_page.first_project_hyperlink.get_attribute('data-nodeid') my_projects_page.first_project_hyperlink.click() # Test & Cleanup project_page = ProjectPage(driver, verify=True) assert project_page.title.text == title, 'Project title incorrect.' osf_api.delete_project(session, guid, None)
def _test_add_contributor_access(self, page): _url = page.driver.current_url second_user = helpers.create_user() page.add_contributor(second_user) self.assertIn(second_user.full_name, [x.full_name for x in page.contributors]) page.close() page = LoginPage() page.log_in(second_user) page.driver.get(_url) page = ProjectPage(driver=page.driver) self.assertIn( second_user.full_name, [x.full_name for x in page.contributors], ) page.close()
def default_project_page(driver, default_project): return ProjectPage(driver, guid=default_project.id)
def project_page_with_file(driver, project_with_file): project_page = ProjectPage(driver, guid=project_with_file.id) project_page.goto() return project_page
###################################################################### # Html elements: ###################################################################### # Main components navbar = dbc.Nav([ dbc.NavItem(dbc.NavLink("Overview", active=True, href="/home", id="link-1")), dbc.NavItem(dbc.NavLink("Project", href="/project", id="link-2")), dbc.NavItem(dbc.NavLink("About Us", href="/team", id="link-3")) ], className='nav-elements') # Access Pages home = HomePage() team = TeamPage() project = ProjectPage() header = HeaderPage() # Content element content = html.Div(id="page-content") ################################################## # Render the application: ################################################## app.layout = html.Div( [dcc.Location(id="url"), header.content, navbar, content]) ################################################## # Handling the render of the pages: ################################################## @app.callback(