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_conversation_post_create_invalid(self):
     """
     Creates a new post but by trying three times --the two first
     times there are required fields left empty and so the warning
     should be triggered instead of the data being submitted.
     """
     driver = self.driver
     login(driver, self.portal, username='******', password='******')
     open(driver, self.portal.absolute_url() + "/workspaces/workspace-1/conversation")
     entryCount0 = len(self.find_elements(By.CSS_SELECTOR, "#entries > .entry", wait=0))
     driver.find_element_by_css_selector("#add-entry.js-ready").click()
     driver.find_element_by_css_selector("#add-entry.js-ready").click()
     driver.find_element_by_css_selector(".action.conversation-add-entry.conversation-add-post").click()
     driver.find_element_by_css_selector(".entry-edit form.js-ready")
     driver.find_element_by_id("form-buttons-save").click()
     errorMsgCount0 = len(self.find_elements(By.CSS_SELECTOR, "#form-error-missingfields"))
     self.assertEqual(errorMsgCount0, 1)
     driver.find_element_by_id("form-buttons-save").click()
     errorMsgCount1 = len(self.find_elements(By.CSS_SELECTOR, "#form-error-missingfields"))
     self.assertEqual(errorMsgCount1, 1)
     title = driver.find_element_by_id("form-widgets-title")
     title.send_keys("New post")
     WebDriverWait(driver, 20).until(lambda l: driver.find_element_by_id("form.widgets.text_ifr"))
     self.typeMce("Shiny content.")
     self.find_element(By.ID, "form-buttons-save").click()
     WebDriverWait(driver, 20).until_not(lambda l: self.is_element_present(By.CSS_SELECTOR, ".exposeMask", wait=0))
     entryCount1 = len(self.find_elements(By.CSS_SELECTOR, "#entries > .entry", wait=0))
     self.assertEqual(entryCount0 + 1, entryCount1)
 def test_view_people(self):
     driver = self.driver
     login(driver, self.portal, username=testing.MANAGER, password=testing.PASSWORD)
     open(driver, self.ws.absolute_url() + "/people")
     self.assertElementWithText(By.CSS_SELECTOR, "li#contentview-people.selected", "People")
     self.assertElementWithText(By.CLASS_NAME, "user-name", u"Hörbert M@ier")
     self.assertElementWithText(By.CLASS_NAME, "user-name", u"Karl Heinz")
Example #4
0
 def _test_ws_create_minimal(self):
     """
     Creates a workspace with the minimal content (just fills the
     workspace name)
     """
     wsName = "New workspace"
     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_elements_by_text("Next")[-1].click()
     self.find_element_by_text("Next").click()
     self.find_element_by_text("Next").click()
     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()
    def test_workspace_with_many_posts(self):
        driver = self.driver
        open(driver, self.portal.absolute_url())

        self.navigate_links(["Challenges", "Challenge 2",
            "Workspace with many posts", "Conversation"])

        # we can see the last 20 posts
        self.assertTrue(self.is_element_present(
            By.LINK_TEXT, u'Post 24 of many'))
        self.assertTrue(self.is_element_present(
            By.LINK_TEXT, u'Post 5 of many'))

        # but not the first four (less than four would be included as orphans)
        self.assertFalse(self.is_element_present(
            By.LINK_TEXT, u'Post 1 of many', wait=0))

        # unless we scroll down to have the automatic pager fetch it
        driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

        # now we can see all of the posts
        self.assertTrue(self.is_element_present(
            By.LINK_TEXT, u'Post 24 of many'))
        self.assertTrue(self.is_element_present(
            By.LINK_TEXT, u'Post 1 of many'))
    def test_edit_member_as_admin(self):
        driver = self.driver
        login(driver, self.portal, username=testing.SITE_ADMIN,
            password=testing.PASSWORD)
        open(driver, self.portal.absolute_url() + "/people/test_user_1/edit")

        title = driver.find_element_by_id("form-widgets-ICovalentMember-title")
        title.clear()
        title.send_keys("Test User 1")

        email = driver.find_element_by_id(
            "form-widgets-ICovalentMember-emailAddress")
        email.clear()
        email.send_keys("*****@*****.**")

        role = driver.find_element_by_id("form-widgets-ICnrdMember-role")
        role.send_keys("teacher")

        # TODO: set portrait

        driver.find_element_by_id("form-buttons-save").click()

        # we expect to arrive on the users profile-page:
        self.assertElementWithText(By.CSS_SELECTOR, "#content-core h1",
            "Test User 1")
    def test_edit_own_profile(self):
        user_id = "test_user_1"
        user_pw = "secret"

        driver = self.driver
        login(driver, self.portal, username=user_id, password=user_pw)
        open(driver, '/'.join([self.portal.absolute_url(), 'people', user_id,
            "edit"]))

        title = driver.find_element_by_id("form-widgets-ICovalentMember-title")
        title.clear()
        title.send_keys("Test User 1")

        email = driver.find_element_by_id(
            "form-widgets-ICovalentMember-emailAddress")
        email.clear()
        email.send_keys("*****@*****.**")

        # TODO: set portrait

        # user shouldn't be able to set the own role:
        self.assertFalse(self.is_element_present(By.ID,
            "form-widgets-ICnrdMember-role", wait=0))

        driver.find_element_by_id("form-buttons-save").click()

        # we expect to arrive on our profile-page:
        self.assertElementWithText(By.CSS_SELECTOR,
            "#content-core h1", "Test User 1")
    def test_reject_all_membership_requests(self):
        """
        Reject all membership requests on the "/new-members" page
        as site admin.
        """

        # log in as site admin:
        login(self.driver, self.portal, username=testing.SITE_ADMIN,
            password=testing.PASSWORD)

        open(self.driver, '/'.join([self.portal.absolute_url(), 'people', '@@new-members']))

        # we expect to arrive on the "new-members" page:
        newMemberForm = self.find_element(By.ID, "newMemberForm")
        self.assertIsNotNone(newMemberForm, 'no new member form found')

        newMemberListLabel = self.find_element(By.CSS_SELECTOR, "label[for=newMemberList]")
        self.assertRegexpMatches(newMemberListLabel.text, 'There are \d+ new membership requests:')

        # approve all new member requests
        self.find_element(By.ID, "reject").click()
        self.find_element(By.ID, "mark_all").click()
        self.find_element(By.CSS_SELECTOR, "input[name=confirm]").click()

        # we expect to arrive on the "new-members" page, but no membership requests exist anymore:
        newMemberForm = self.find_element(By.ID, "newMemberForm")
        self.assertIsNotNone(newMemberForm, 'no new member form found')

        warn_messages = self.find_elements(By.CSS_SELECTOR, "div.portalMessage.warn")
        self.assertEqual(len(warn_messages), 1)
        self.assertRegexpMatches(warn_messages[0].text, '\d+ members have been rejected.')

        info_messages = self.find_elements(By.CSS_SELECTOR, "div.portalMessage.info")
        self.assertEqual(len(info_messages), 1)
        self.assertEqual(info_messages[0].text, 'Nobody is currently requesting portal membership.')
 def test_ws_conversation_entry_edit_submit(self):
     """
     Edits an already existing entry.
     """
     driver = self.driver
     login(driver, self.portal, username='******', password='******')
     open(driver, self.portal.absolute_url() + "/workspaces/workspace-1/conversation")
     entryCount0 = len(driver.find_elements_by_css_selector("#entries > .entry"))
     originalTitle = driver.find_element_by_css_selector("#entries > .entry:last-child h2.entry-title a").text
     originalContent = driver.find_element_by_css_selector("#entries > .entry:last-child .entry-body").text
     driver.find_element_by_css_selector("#column-content.js-ready")
     driver.find_elements_by_css_selector("#entries > .entry:last-child a.conversation-edit-entry")[0].click()
     driver.find_element_by_css_selector(".entry-edit form.js-ready")
     title = driver.find_element_by_id("form-widgets-title")
     title.clear()
     title.send_keys("New title")
     WebDriverWait(driver, 20).until(lambda l: driver.find_element_by_id("form.widgets.text_ifr"))
     self.typeMce("New content.")
     driver.find_element_by_id("form-buttons-save").click()
     WebDriverWait(driver, 20).until(lambda l: not self.is_element_present(By.CSS_SELECTOR, ".exposeMask", wait=0))
     # Check that the number of entries remains the same
     entryCount1 = len(driver.find_elements_by_css_selector("#entries > .entry"))
     self.assertEqual(entryCount0, entryCount1)
     # Check that the contents of the edited entry are left unmodified
     finalTitle = driver.find_element_by_css_selector("#entries > .entry:last-child h2.entry-title a").text
     finalContent = driver.find_element_by_css_selector("#entries > .entry:last-child .entry-body").text
     assert originalTitle != finalTitle
     assert originalContent != finalContent
 def _test_ws_conversation_timeline_scroll(self):
     """
     Scrolls the page and checks that the timeline is updated
     accordingly.
     """
     pagePath = "/workspaces/workspace-with-many-posts/conversation"
     driver = self.driver
     login(driver, self.portal, username=testing.MANAGER,
         password=testing.PASSWORD)
     open(driver, self.portal.absolute_url() + pagePath)
     slider = driver.find_element_by_css_selector("#slider.js-ready")
     timelineHandle = slider.find_element_by_class_name("ui-slider-handle")
     timelineLinks = slider.find_elements_by_css_selector(".timeline-links a")
     entries = self.find_elements(By.CSS_SELECTOR, "#entries > .entry")
     timelineHandleLeftBefore = float(timelineHandle.value_of_css_property("left")[:-2]) # trim the "px" at the end
     linkWidthBefore = 0
     lastTimelineLink = timelineLinks[0]
     lastTargetId = lastTimelineLink.get_attribute("href").split("#")[1]
     endOfScroll = False
     assert len(timelineLinks) > len(entries) # This makes us sure that there is some way down to scroll, otherwise the test makes no sense
     for index, link in enumerate(reversed(timelineLinks)):
         if not endOfScroll:
             entry = entries[index]
             scrollTo = entry.location["y"] - driver.find_element_by_id("header").size["height"]
             driver.execute_script("window.scrollTo(0, " + str(scrollTo) + ");") # scroll down to the current entry
             if self.is_element_present(By.CSS_SELECTOR, ".exposeMask", wait=0):
                 WebDriverWait(driver, 20).until_not(lambda l: self.is_element_present(By.CSS_SELECTOR, ".exposeMask", wait=0))
                 endOfScroll = self.is_element_present(By.ID, lastTargetId, wait=0) # After the last batch is loaded, we have no way to be totally sure that we have more way to scroll down, so we stop the test here
             if linkWidthBefore > 0 and not endOfScroll:
                 WebDriverWait(driver, 5).until(lambda l: timelineHandleLeftBefore > float(timelineHandle.value_of_css_property("left")[:-2]))
                 timelineHandleLeft = float(timelineHandle.value_of_css_property("left")[:-2])
                 assert timelineHandleLeftBefore > timelineHandleLeft # If the width of the link was greater than 0, check that the timeline handle has moved
                 timelineHandleLeftBefore = timelineHandleLeft
             linkWidthBefore = link.size['width']
Example #11
0
    def test_search_field(self):
        """ We need to make sure links in livesearch are updated and link to
            correct search results view.
        """

        portal = self.layer['portal']
        sel = self.layer['selenium']
        open(sel, portal.absolute_url())
        search_form = sel.find_element_by_id('portal-searchbox')

        # Of course the form is linked to @@search, isn't it?
        form = search_form.find_element_by_name('searchform')
        self.assert_(
            form.get_attribute('action') ==
            'http://*****:*****@@search')

        search_field = search_form.find_element_by_id('searchGadget')
        search_field.send_keys('wel')
        time.sleep(1)
        # livesearch should be visible now...
        self.assert_(search_form.find_element_by_id('LSResult').is_displayed())
        # ... and we should have at least 2 'Advanced Search' links
        adv = search_form.find_elements_by_partial_link_text('Advanced Search')
        for link in adv:
            href = link.get_attribute('href')
            self.assert_(href == 'http://*****:*****@@search')
Example #12
0
    def test_search_field(self):

        """ We need to make sure links in livesearch are updated and link to
            correct search results view.
        """

        portal = self.layer['portal']
        sel = self.layer['selenium']
        open(sel, portal.absolute_url())
        search_form = sel.find_element_by_id('portal-searchbox')

        # Of course the form is linked to @@search, isn't it?
        form = search_form.find_element_by_name('searchform')
        self.assert_(form.get_attribute('action') ==
                     'http://*****:*****@@search')

        search_field = search_form.find_element_by_id('searchGadget')
        search_field.send_keys('wel')
        time.sleep(1)
        # livesearch should be visible now...
        self.assert_(search_form.find_element_by_id('LSResult').is_displayed())
        # ... and we should have at least 2 'Advanced Search' links
        adv = search_form.find_elements_by_partial_link_text('Advanced Search')
        for link in adv:
            href = link.get_attribute('href')
            self.assert_(href == 'http://*****:*****@@search')
    def test_project_ws_accept_invitation(self):
        pat.login(self.portal, testing.STUDENT)
        new_ws = ws_helpers.create_workspace(self.workspaces,
            "ws_to_be_added_to_project", title=u"Workspace for project")
        pat.login(self.portal, self.project_admin.id)
        self.project.invite_workspace(new_ws)

        login(self.driver, self.portal, username=testing.STUDENT,
            password=testing.PASSWORD)
        open(self.driver, new_ws.absolute_url())

        # accept invitation
        self.navigate_links(["Join the project"])

        # check if ws was added to project
        self.assertElementWithText(By.CSS_SELECTOR, ".portalMessage",
            u"“{0}” is now part of the project “{1}”.".format(new_ws.title, self.project.title))
        page_title_project = self.find_element(
            By.CSS_SELECTOR, "#page-title .workspace-project")
        self.assertEquals(page_title_project.text, self.project.title)

        page_title_project.click()

        self.assertElementWithText(By.CSS_SELECTOR,
            ".project-workspaces h3>a", new_ws.title)
Example #14
0
    def test_relevance_sorting_after_ajax(self):
        """The reason to test this - weird behavior of the link to 'relevance'
           sorting option after some ajax calls.
        """

        # First we test default sorting that should be 'relevance':
        portal = self.layer['portal']
        sel = self.layer['selenium']
        open(sel, portal.absolute_url() + '/@@search?SearchableText=Foo')
        s = sel.find_element_by_id('sorting-options')
        curr = s.find_element_by_tag_name('strong')
        self.assert_('relevance' in curr.text,
                     'Relevance is not default sorting option')

        # Now we try to change sorting and come back to 'relevance' to see that
        # getting back to it highlights the corresponding item # in the sorting
        # bar:
        s.find_element_by_partial_link_text('date').click()
        # At this point we make an ajax call so it's better to wait for it to
        # be finished:
        time.sleep(1)
        curr = s.find_element_by_tag_name('strong')
        self.assert_('date' in curr.text,
                     'Date is not highlighted sorting option after sorting.')

        s.find_element_by_partial_link_text('relevance').click()
        # At this point we make an ajax call so it's better to wait for it to
        # be finished:
        time.sleep(1)
        try:
            curr = s.find_element_by_tag_name('strong')
            self.assert_('relevance' in curr.text,
                         'Relevance is not highlighted sorting option.')
        except NoSuchElementException:
            self.fail("No highlighted element found after ajax call.")
    def test_workspace_with_files(self):
        driver = self.driver
        path_to_conversation = "/workspaces/workspace-with-files/conversation"
        open(driver, self.portal.absolute_url() + path_to_conversation)

        self.assertTrue(self.is_element_present(
            By.LINK_TEXT, u'Post with attached files'))
        self.assertTrue(self.is_element_present(
            By.LINK_TEXT, u'File with meta-data'))
        self.assertTrue(self.is_element_present(
            By.LINK_TEXT, u'Another File with meta-data'))

        self.assertTrue(self.is_element_present(
            By.LINK_TEXT, u'Post with attached file that has no meta-data'))
        self.assertFalse(self.is_element_present(
            By.LINK_TEXT, u'file_without_meta_data.png', wait=0))
        self.assertFalse(self.is_element_present(
            By.LINK_TEXT, u'another_file_without_meta_data.png', wait=0))

        login(driver, self.portal, username='******', password='******')
        open(driver, self.portal.absolute_url() + path_to_conversation)

        self.assertElementWithText(By.CSS_SELECTOR,
            '#fileMetaDataHelperMessage a[href$="file_without_meta_data/edit"]',
            'file_without_meta_data.png')
        self.assertElementWithText(By.CSS_SELECTOR,
            '#fileMetaDataHelperMessage a[href$="another_file_without_meta_data/edit"]',
            'another_file_without_meta_data.png')
    def test_project_ws_invite(self):
        pat.login(self.portal, testing.STUDENT)
        new_ws = ws_helpers.create_workspace(self.workspaces,
            "ws_to_be_added_to_project", title=u"Workspace for project")
        pat.login(self.portal, self.project_admin.id)

        login(self.driver, self.portal, username=self.project_admin.id,
            password=testing.PASSWORD)

        open(self.driver, self.project.absolute_url())

        self.driver.find_elements_by_link_text("Preferences")[1].click()
        self.navigate_links(["Members"])

        widget = self.driver.find_element(By.CSS_SELECTOR, '#formfield-form-widgets-invited_workspaces-widgets-query input[type=text]')
        widget.send_keys("for project")
        suggestion = self.driver.find_element(By.CSS_SELECTOR, '.ac_results li')
        suggestion.click()

        self.driver.find_element_by_id('form-buttons-save').click()

        # wait while the page loads
        self.find_element_with_text("Changes saved")
        transaction.commit()

        # check if we see an invitation on the ws info page
        open(self.driver, new_ws.absolute_url())
        self.assertElementWithText(By.CSS_SELECTOR,
            ".project-invitation a.title>h1", self.project.title)
Example #17
0
    def test_ws_create_cancel(self):
        """
        Opens a workspace creation form but then cancels.
        """
        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()

        # work around "StaleElementReferenceException", which happens because
        # some js-magic replaces "#form-buttons-cancel" between finding and
        # clicking:

        from selenium.common.exceptions import (StaleElementReferenceException,
            NoSuchElementException, TimeoutException)

        def cancel_clicked(self, i=0):
            try:
                self.find_element(By.ID, "form-buttons-cancel", wait=1).click()
            except (StaleElementReferenceException, NoSuchElementException):
                pass
            else:
                return

            if i > self.implicitly_wait:
                raise TimeoutException('Cancel button not found.')

            cancel_clicked(self, i+1)

        cancel_clicked(self)

        self.assertEqual(u"Challenge 1 — CNRD Virtual Center", self.page_title)
    def test_project_ws_decline_invitation(self):
        pat.login(self.portal, testing.STUDENT)
        new_ws = ws_helpers.create_workspace(self.workspaces,
            "ws_to_be_added_to_project", title=u"Workspace for project")
        pat.login(self.portal, self.project_admin.id)
        self.project.invite_workspace(new_ws)

        login(self.driver, self.portal, username=testing.STUDENT,
            password=testing.PASSWORD)
        open(self.driver, new_ws.absolute_url())

        # decline invitation
        self.navigate_links(["Decline invitation"])

        # check the portal message
        msg = u"You have declined the invitation to ”{project_title}“."
        self.assertElementWithText(By.CSS_SELECTOR, ".portalMessage",
            msg.format(project_title=self.project.title))

        # ensure that there is no invitation on the ws info page anymore
        self.assertFalse(self.is_element_present(By.CSS_SELECTOR,
            ".project-invitation", wait=0))

        # assert that the project isn't mentioned next to the ws title
        self.assertFalse(self.is_element_present(By.CSS_SELECTOR,
            "#page-title .workspace-project", wait=0))
    def test_project_info_navigation_anonymous(self):
        pat.logout()
        open(self.driver, self.project.absolute_url())
        nav_links = self.find_elements(By.CSS_SELECTOR, ".content-views>li>a")
        nav_link_texts = [x.text for x in nav_links]

        self.assertListEqual(nav_link_texts, [u'Information', u'Conversation'])
    def test_ws_conversation_task_create(self):
        """
        Creates a new task.
        """
        driver = self.driver
        login(driver, self.portal, username=testing.MANAGER, password=testing.PASSWORD)
        open(driver, self.portal.absolute_url() + "/workspaces/workspace-1/conversation")
        entryCount0 = len(self.find_elements(By.CSS_SELECTOR, "#entries > .entry"))
        driver.find_element_by_css_selector("#add-entry.js-ready").click()
        driver.find_element_by_link_text("Task").click()
        driver.find_element_by_id("form-widgets-title").send_keys("New task")
        WebDriverWait(driver, 20).until(lambda l: driver.find_element_by_id("form.widgets.text_ifr"))
        self.typeMce("Please complete this task soon.")
        self.navigate_links(["Pick date"])
        last_day_in_date_picker = self.find_element(
            By.CSS_SELECTOR, "#calweeks .calweek:last-child .caloff:last-child")
        last_day_in_date_picker.click()

        import time
        time.sleep(1)

        driver.find_element_by_id("form-buttons-save").click()

        time.sleep(1)

        WebDriverWait(driver, 20).until_not(lambda l: self.is_element_present(By.CSS_SELECTOR, ".exposeMask", wait=0))
        entryCount1 = len(self.find_elements(By.CSS_SELECTOR, "#entries > .entry"))
        self.assertEqual(entryCount0 + 1, entryCount1)
    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)
Example #22
0
 def test_nested_hidewhen(self):
     mydb = self.layer['portal'].mydb
     sel = self.layer['selenium']
     import_file('hideWhenTest.xml', mydb)
     selenium_layers.open(sel, self.layer['portal'].absolute_url())
     self.authenticate(sel)
     selenium_layers.open(sel, mydb.with_subform.absolute_url())
     self.do_check_dynamic_hidewhen(sel)
    def test_title_and_welcome_page(self):
        driver = self.driver
        open(driver, self.portal.absolute_url())

        self.assertEqual(u"CNRD Virtual Center", driver.title)

        welcome_message = driver.find_element_by_id("cnrd-welcome-message").text
        self.assertIn(u"Welcome to the CNRD Virtual Center!", welcome_message)
 def test_personal_facade_anonymous(self):
     """
     Attempts to visit a user's personal profile without being
     authenticated. Shouldn't be able to see the contents.
     """
     driver = self.driver
     open(driver, self.portal.absolute_url() + "/people/test_user_1")
     self.assertEqual(len(self.find_elements(By.CSS_SELECTOR, ".related-challenges", wait=0)), 0)
    def test_workspace_2(self):
        driver = self.driver
        open(driver, self.portal.absolute_url())

        self.navigate_links(["Challenges", "Challenge 2", "Workspace 2",
            "Conversation"])

        body = self.body_text
        self.assertIn(u"Nothing has been posted yet in this workspace.", body)
    def test_project_info_workspaces(self):
        # login(self.driver, self.portal, username=testing.STUDENT,
        #     password=testing.PASSWORD)
        open(self.driver, self.project.absolute_url())

        ws_links = self.find_elements(By.CSS_SELECTOR, ".project-workspaces h3>a")
        ws_link_texts = [x.text for x in ws_links]

        self.assertListEqual(ws_link_texts, [self.ws.title])
    def test_project_info_navigation_project_member(self):
        login(self.driver, self.portal, username=self.project_member.id,
            password=testing.PASSWORD)
        open(self.driver, self.project.absolute_url())
        nav_links = self.find_elements(By.CSS_SELECTOR, ".content-views>li>a")
        nav_link_texts = [x.text for x in nav_links]

        self.assertListEqual(nav_link_texts, [
            u'Information', u'Conversation', u'People', u'Material'])
Example #28
0
 def test_hidewhen(self):
     # Import our sample database
     mydb = self.layer['portal'].mydb
     sel = self.layer['selenium']
     import_file('hideWhenTest.xml', mydb)
     selenium_layers.open(sel, self.layer['portal'].absolute_url())
     self.authenticate(sel)
     selenium_layers.open(sel, mydb.form1.absolute_url())
     self.do_check_dynamic_hidewhen(sel)
Example #29
0
    def test_basic_search(self):

        portal = self.layer['portal']
        sel = self.layer['selenium']

        # Open search form
        open(sel, portal.absolute_url() + '/@@search')

        # Is search filter hidden?
        f = sel.find_element_by_id('search-filter')
        self.failIf(f.is_displayed())

        # Is 'relevance' the current/default sorting option and thus
        # is not clickable?
        sorter = sel.find_element_by_id('sorting-options')
        self.assertEquals(sorter.find_elements_by_link_text('relevance'), [])

        # By default there are no search results because there is no
        # SearchableText specified in request when accessing the form directly:
        res_num = sel.find_element_by_id('search-results-number')
        res = sel.find_element_by_id('search-results')
        self.assertEquals(res_num.text, '0')
        self.assertEquals(res.text, 'No results were found.')

        # Now we want to get results with all elements in the site.
        # we use the main search form for this search
        content = sel.find_element_by_id('content')
        main_search_form = content.find_element_by_name('searchform')
        search_field = main_search_form.find_element_by_name('SearchableText')
        search_button = main_search_form.find_element_by_css_selector(
            '.searchButton')
        search_field.send_keys('Foo')
        search_button.click()

        # We should give the view some time in order to finish the animation of
        # the search results
        time.sleep(1)

        # We should get our 5 'Foo' elements:
        res_num = sel.find_element_by_id('search-results-number')
        self.assertEquals(res_num.text, '5')
        # Filter should still be hidden:
        f = sel.find_element_by_id('search-filter')
        self.failIf(f.is_displayed())

        # Make sure we have search results returned after clicking main
        # 'Search' button on the search results form:
        sel.find_elements_by_class_name('searchButton')[1].click()
        # We should give the view some time in order to finish the animation of
        # the search results
        time.sleep(1)
        # And the search results are actually visible, aren't they?:
        self.assert_(
            sel.find_element_by_id('search-results').is_displayed(),
            "Search results are not visible.")
    def test_workspace_with_tasks(self):
        driver = self.driver
        open(driver, self.portal.absolute_url())

        self.navigate_links(["Challenges", "Challenge 2",
            "Workspace with tasks", "Conversation"])

        self.assertTrue(self.is_element_present(
            By.LINK_TEXT, u'Task in the future'))
        self.assertTrue(self.is_element_present(
            By.LINK_TEXT, u'Task in the past'))
    def test_basic_search(self):

        portal = self.layer['portal']
        sel = self.layer['selenium']

        # Open search form
        open(sel, portal.absolute_url() + '/@@search')

        # Is search filter hidden?
        f = sel.find_element_by_id('search-filter')
        self.assertFalse(f.is_displayed())

        # Is 'relevance' the current/default sorting option and thus
        # is not clickable?
        sorter = sel.find_element_by_id('sorting-options')
        self.assertEqual(sorter.find_elements_by_link_text('relevance'), [])

        # By default there are no search results because there is no
        # SearchableText specified in request when accessing the form directly:
        res_num = sel.find_element_by_id('search-results-number')
        res = sel.find_element_by_id('search-results')
        self.assertEqual(res_num.text, '0')
        self.assertEqual(res.text, 'No results were found.')

        # Now we want to get results with all elements in the site.
        # we use the main search form for this search
        content = sel.find_element_by_id('content')
        main_search_form = content.find_element_by_name('searchform')
        search_field = main_search_form.find_element_by_name('SearchableText')
        search_button = main_search_form.find_element_by_css_selector('.searchButton')
        search_field.send_keys('Foo')
        search_button.click()

        # We should give the view some time in order to finish the animation of
        # the search results
        time.sleep(1)

        # We should get our 5 'Foo' elements:
        res_num = sel.find_element_by_id('search-results-number')
        self.assertEqual(res_num.text, '5')
        # Filter should still be hidden:
        f = sel.find_element_by_id('search-filter')
        self.assertFalse(f.is_displayed())

        # Make sure we have search results returned after clicking main
        # 'Search' button on the search results form:
        sel.find_elements_by_class_name('searchButton')[1].click()
        # We should give the view some time in order to finish the animation of
        # the search results
        time.sleep(1)
        # And the search results are actually visible, aren't they?:
        self.assert_(sel.find_element_by_id('search-results').is_displayed(),
                     "Search results are not visible.")
    def test_add_group(self):
        login(self.driver, self.portal, username=testing.MANAGER,
            password=testing.PASSWORD)
        open(self.driver, self.ws.absolute_url() + "/@@material")

        self.navigate_links(["Add Group"])
        name_input = self.find_element(By.ID, "group_name")
        new_group_label = "My new group"
        name_input.send_keys(new_group_label)
        self.find_element(By.ID, "save").click()

        self.assert_group_with_items(new_group_label, [])
    def test_challenges(self):
        driver = self.driver
        open(driver, self.portal.absolute_url())

        driver.find_element_by_link_text("Challenges").click()
        self.assertEqual(u"Challenges — CNRD Virtual Center", self.page_title)

        driver.find_element_by_link_text("Challenge 1").click()
        self.assertEqual(u"Challenge 1 — CNRD Virtual Center", self.page_title)

        driver.find_element_by_link_text("Challenges").click()
        driver.find_element_by_link_text("Challenge 2").click()
        self.assertEqual(u"Challenge 2 — CNRD Virtual Center", self.page_title)
    def login(self):
        """Login to the portal as Manager."""
        open(self.driver, self.portal.absolute_url() + '/login_form')

        # login as user
        type(self.driver, "__ac_name", TEST_USER_NAME)
        type(self.driver, "__ac_password", TEST_USER_PASSWORD)
        click(self.driver, "submit")
        time.sleep(5)
        self.driver.find_element_by_id("personaltools-logout")

        # assign role to user
        setRoles(self.portal, TEST_USER_ID, ['Manager'])
 def test_ws_conversation_entry_delete_cancel(self):
     """
     Opens the delete confirmation dialog for an entry but then
     cancels.
     """
     driver = self.driver
     login(driver, self.portal, username='******', password='******')
     open(driver, self.portal.absolute_url() + "/workspaces/workspace-1/conversation")
     entryCount0 = len(self.find_elements(By.CSS_SELECTOR, "#entries > .entry", wait=0))
     self.find_elements(By.CSS_SELECTOR, "#column-content.js-ready .conversation-delete-entry", wait=0)[0].click()
     driver.find_element_by_css_selector("#delete_confirmation input[name='form.button.Cancel']").click()
     WebDriverWait(driver, 20).until_not(lambda l: self.is_element_present(By.CSS_SELECTOR, ".exposeMask", wait=0))
     entryCount1 = len(self.find_elements(By.CSS_SELECTOR, "#entries > .entry", wait=0))
     self.assertEqual(entryCount0, entryCount1)
Example #36
0
    def test_search_box(self):
        """We need to make sure word in search box are updated and getting to
           same words
        """

        portal = self.layer['portal']
        sel = self.layer['selenium']
        open(sel, portal.absolute_url())

        search_form = sel.find_element_by_id('portal-searchbox')
        search_field = search_form.find_element_by_id('searchGadget')
        search_button = search_form.find_element_by_css_selector(
            '.searchButton')

        word = u'検索'  # for Japanese test
        search_field.send_keys(word)
        search_button.click()
        time.sleep(1)
        content = sel.find_element_by_id('content')
        main_search_form = content.find_element_by_name('searchform')
        main_search_field = main_search_form.find_element_by_name(
            'SearchableText')
        self.assert_(main_search_field.get_attribute('value') == word)
Example #37
0
 def test_overlay_hidewhen(self):
     mydb = self.layer['portal'].mydb
     sel = self.layer['selenium']
     import_file('hideWhenTest.xml', mydb)
     selenium_layers.open(sel, self.layer['portal'].absolute_url())
     self.authenticate(sel)
     selenium_layers.open(sel, mydb.with_overlay.absolute_url())
     selenium_layers.click(sel, "a#a_datagrid_addrow")
     sel.switch_to_frame(0)
     selenium_layers.type(sel, 'a', '123')
     selenium_layers.click(sel, "//option[@value='A']")
     # Submitting now should warn us that 'c' has no value
     sel.find_element_by_xpath("//input[@name='plomino_save']").click()
     # An alert should pop up. We dismiss it
     sel.switch_to_alert().accept()
     # But when we fill it in, it should work
     selenium_layers.type(sel, 'c', 'A value for c!')
     sel.find_element_by_xpath("//input[@name='plomino_save']").click()
     # At this point the usual selenium wait-for-page-loaded doesn't work
     # because we intercept the submit event and do ajax validation
     self.wait_ajax_calls()
     sel.switch_to_window('')
     rows = sel.find_elements_by_css_selector(
         "table#a_datagrid_datagrid tbody tr")
     # There should be one row in the datagrid
     self.assertEqual(len(rows), 1)
     # XXX This belongs to another test
     # Ensure the newly added record is editable
     sel.find_elements_by_css_selector(
         "table#a_datagrid_datagrid tbody tr")[0].click()
     sel.find_element_by_css_selector('#a_datagrid_editrow').click()
     sel.switch_to_frame(0)
     field_a = sel.find_element_by_xpath("//input[@name='a']")
     field_value = sel.execute_script(
         "return jQuery(arguments[0]).attr('value')", field_a)
     self.assertEqual(field_value, '123')
Example #38
0
    def test_basic_search(self):
        """
        Check if all items are displayed correctly in a simple search
        """
        portal = self.layer['portal']
        sel = self.layer['selenium']

        # Open search form
        open(sel, portal.absolute_url() + '/@@search')

        # Is 'relevance' the current/default sorting option and thus
        # is not clickable?
        sorter = sel.find_element_by_id('sorting-options')
        self.assertEquals(sorter.find_elements_by_link_text('relevance'), [])

        # By default there are no search results because there is no
        # SearchableText specified in request when accessing the form directly:
        res_num = sel.find_element_by_id('search-results-number')
        self.assertEquals(res_num.text, '90 on 90')

        #Now we check if all tags are displayed and which is selected tab
        tabs = sel.find_elements_by_class_name('tabElement')
        self.assertEquals(len(tabs), 3)
        selected_tab = sel.find_element_by_class_name(
            'active').find_element_by_css_selector('a')
        self.assertEquals(selected_tab.text, "All")

        #Check if there are some filters
        filters = sel.find_element_by_id(
            'indexes-options').find_elements_by_class_name('field')
        self.assertEquals(len(filters), 1)
        subject_div = sel.find_element_by_id(
            'indexes-options').find_element_by_class_name('field')
        self.assertEquals(
            subject_div.find_element_by_tag_name('h3').text, "Subject")
        subjects = [
            x.get_attribute('value')
            for x in subject_div.find_elements_by_tag_name('input')
        ]
        self.assertEquals(subjects, ['apple', 'kiwi', 'mango'])

        #Now we try to filter search results clicking on a tab.
        documents = sel.find_element_by_class_name('documents')
        documents.click()
        # We should give the view some time in order to finish the animation of
        # the search results
        time.sleep(1)
        res_num = sel.find_element_by_id('search-results-number')
        self.assertEquals(res_num.text, '85 on 90')

        #checking which is selected tab
        selected_tab = sel.find_element_by_class_name(
            'active').find_element_by_css_selector('a')
        self.assertEquals(selected_tab.text, "Documents")

        #Now we check if all tags are displayed and which is selected tab
        subject_div = sel.find_element_by_id(
            'indexes-options').find_element_by_class_name('field')
        self.assertEquals(
            subject_div.find_element_by_tag_name('h3').text, "Subject")
        subjects = subject_div.find_elements_by_tag_name('input')
        self.assertEquals(len(subjects), 2)

        #now we try to filter also by subject
        subj_apple = subject_div.find_element_by_id("Subject_1")
        self.assertEquals(subj_apple.get_attribute('value'), 'apple')
        subj_apple.click()
        # We should give the view some time in order to finish the animation of
        # the search results
        time.sleep(1)
        res_num = sel.find_element_by_id('search-results-number')
        self.assertEquals(res_num.text, '5 on 10')

        #we check if "apple" is selected
        subject_div = sel.find_element_by_id(
            'indexes-options').find_element_by_class_name('field')
        subj_apple = subject_div.find_element_by_id("Subject_1")
        self.assertEquals(subj_apple.is_selected(), True)

        #now we try to remove all the filters for Subjects
        remove_link = subject_div.find_element_by_id("deselect-Subject")
        remove_link.click()
        # We should give the view some time in order to finish the animation of
        # the search results
        time.sleep(1)
        res_num = sel.find_element_by_id('search-results-number')
        self.assertEquals(res_num.text, '85 on 90')
        #we check if "apple" isn't selected
        subject_div = sel.find_element_by_id(
            'indexes-options').find_element_by_class_name('field')
        subj_apple = subject_div.find_element_by_id("Subject_1")
        self.assertEquals(subj_apple.is_selected(), False)
Example #39
0
 def open(self, url):
     selenium_layers.open(self.selenium, url)