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_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.')
Exemplo n.º 3
0
    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_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_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']
 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_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)
    def test_add_content(self):
        driver = self.driver

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

        self.navigate_links(["Challenges", self.challenge_title,
            self.workspace_title])

        driver.find_element_by_id("add-entry").click()
        driver.find_element_by_link_text("Post").click()
        driver.find_element_by_id("form-widgets-title").send_keys("Selenium")
        title = u"Selenium"
        text = u"This Selenium-stuff is really cool!"
        self.typeMce(text)
        driver.find_element_by_id("form-buttons-save").click()

        # wait until the popup disappears:
        WebDriverWait(driver, 10).until_not(
            lambda l: self.is_element_present(
                By.CSS_SELECTOR, ".exposeMask", wait=0))

        # make shure our post appeared on the conversation:
        self.assertEqual(title,
            driver.find_element_by_css_selector("h2.entry-title").text)
        self.assertEqual(text,
            driver.find_element_by_css_selector("div.entry-body").text)
    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))
Exemplo n.º 10
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)
Exemplo n.º 11
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_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_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))
Exemplo n.º 14
0
 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")
    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)
    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_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)
Exemplo n.º 18
0
    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'])
Exemplo n.º 19
0
    def test_invite_manager(self):
        driver = self.driver
        login(driver, self.portal, username=self.ws_owner.id,
            password='******')
        open(driver, self.challenge.absolute_url())
        self.navigate_links(["Create Workspace", "Members"])

        driver.find_element_by_id(
            'form-widgets-autoAcceptNewMembers-0').click()
        widget = driver.find_element(By.CSS_SELECTOR, '#form-widgets-invitedManagers-chosen input[type=text]')
        widget.click()
        widget.send_keys("ka")
        driver.find_element(By.CSS_SELECTOR, '#form-widgets-invitedManagers-chosen .active-result').click()

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

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

        if not self.mailhost.messages:
            self.fail("No email received")

        message = self.mailhost.messages[-1]
        msg_text = message.get_payload().strip().replace('=\n', '')
        self.assertEqual(message.get_charset(), 'utf-8')
        self.assertIsInstance(message['To'], basestring)
        self.assertEqual(message['To'], u'Karl Heinz <*****@*****.**>')
        self.assertIsInstance(message['From'], basestring)
        self.assertEqual(message['From'],
            u'CNRD Virtual Center <*****@*****.**>')
        self.assertEqual(unicode(message['Subject']), u"[CNRD Virtual Center] "
            u"You’ve been invited to co-administrate “Workspace Draft”")
        self.assertIn('asks you to help with its administration.', msg_text)

        open(driver, self.portal.absolute_url() + "/logout")

        # follow the invitation and join:
        join_url = msg_text.split('\n')[-1]
        open(driver, join_url)
        self.assertTrue(self.is_element_present(By.ID, 'login_form'))

        driver.find_element_by_id('__ac_name').send_keys(self.invitee.id)
        driver.find_element_by_id('__ac_password').send_keys(testing.PASSWORD)
        driver.find_element(By.NAME, 'submit').click()

        self.assertElementWithText(By.CLASS_NAME, 'portalMessage',
            'Welcome! You are now logged in.')
        self.assertElementWithText(By.CLASS_NAME, 'portalMessage',
            'Welcome to the workspace.')
        self.assertElementWithText(By.CLASS_NAME, 'portalMessage',
            'You are a co-administrator in this workspace.')
        # TODO: look for the preferences-link
        self.assertElementWithText(By.TAG_NAME, 'a', 'Leave Workspace')
Exemplo n.º 20
0
    def test_site_clean(self):
        driver = self.driver

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

        self.navigate_links(["Challenges", self.challenge_title,
            self.workspace_title])

        # make shure our post is NOT here anymore:
        body = self.body_text
        self.assertIn(u"Nothing has been posted yet in this workspace.", body)
    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_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)
 def test_ws_conversation_reply_add_cancel(self):
     """
     Opens the dialog to add a reply to the first entry and then
     cancels.
     """
     driver = self.driver
     login(driver, self.portal, username='******', password='******')
     open(driver, self.portal.absolute_url() + "/workspaces/workspace-1/conversation")
     replyCount0 = len(self.find_elements(By.CSS_SELECTOR, "#column-content.js-ready #entries > .entry:first-child .entry-replies > *", wait=0))
     driver.find_element_by_css_selector("#entries > .entry:first-child .conversation-add-entry").click()
     driver.find_element_by_id("form-buttons-cancel").click()
     WebDriverWait(driver, 20).until_not(lambda l: self.is_element_present(By.CSS_SELECTOR, ".exposeMask", wait=0))
     replyCount1 = len(self.find_elements(By.CSS_SELECTOR, "#entries > .entry:first-child .entry-replies > *", wait=0))
     self.assertEqual(replyCount0, replyCount1)
    def test_drag_drop(self):
        login(self.driver, self.portal, username=testing.MANAGER,
            password=testing.PASSWORD)
        open(self.driver, self.ws.absolute_url() + "/@@material")

        link1 = self.links[0]
        link2 = self.links[1]
        self.perform_drag_drop(link1.rmGroup, link2.rmGroup)

        open(self.driver, self.ws.absolute_url() + "/@@material")

        self.assert_group_with_items("Group 1", [])
        self.assert_group_with_items(
            "Group 2", [u"Link 1", u"Link 2"], sort=True)
    def test_delete_group(self):
        login(self.driver, self.portal, username=testing.MANAGER,
            password=testing.PASSWORD)
        open(self.driver, self.ws.absolute_url() + "/@@material")

        group = self.find_group_by_partial_handle("_group-1 ")
        delete_link = group.find_element(By.CLASS_NAME, "delete-group")
        delete_link.click()
        self.find_element(By.ID, "delete").click()

        WebDriverWait(self.driver, self.implicitly_wait).until_not(
            lambda l: self.find_elements_by_text("Group 1", wait=0))

        self.assert_group_with_items(
            u'Miscellaneous', [self.links[0].title, self.misc_link.title])
 def test_ws_conversation_poll_rating(self):
     """
     Votes in a rating
     """
     driver = self.driver
     login(driver, self.portal, username=testing.MANAGER,
         password=testing.PASSWORD)
     open(driver, self.portal.absolute_url() + "/workspaces/workspace-with-polls/conversation")
     ratingChoice = 3
     driver.find_elements_by_css_selector(".entry .poll-options.rating label")[ratingChoice - 1].click()
     driver.find_element_by_css_selector(".entry .poll-body.rating input[type='submit']").click()
     WebDriverWait(driver, 20).until(lambda l: 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))
     ratingResult = driver.find_element_by_css_selector(".entry .poll-result-rating-result").text
     self.assertEqual(float(ratingResult), float(ratingChoice))
 def test_ws_conversation_reply_add_submit(self):
     """
     Adds a new reply to the first entry.
     """
     driver = self.driver
     login(driver, self.portal, username='******', password='******')
     open(driver, self.portal.absolute_url() + "/workspaces/workspace-1/conversation")
     replyCount0 = len(self.find_elements(By.CSS_SELECTOR, "#column-content.js-ready #entries > .entry:first-child .entry-replies > *", wait=0))
     driver.find_element_by_css_selector("#entries > .entry:first-child .conversation-add-entry").click()
     WebDriverWait(driver, 20).until(lambda l: driver.find_element_by_id("form.widgets.text_ifr"))
     self.typeMce("I totally disagree.")
     driver.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))
     replyCount1 = len(self.find_elements(By.CSS_SELECTOR, "#entries > .entry:first-child .entry-replies > *", wait=0))
     self.assertEqual(replyCount0 + 1, replyCount1)
Exemplo n.º 28
0
    def test_ws_publish(self):
        """
        Publishes an unpublished workspace, first for site members only,
        then for site members + public description, then for the web,
        then retracts to site-members-only again.
        """
        driver = self.driver
        login(driver, self.portal, username=testing.MANAGER,
            password=testing.PASSWORD)

        open(driver,
            self.portal.absolute_url() + "/workspaces/my-workspace-draft")
        self.assertElementWithText(By.CSS_SELECTOR, "body",
            "This workspace is not yet published.")

        action = "Publish for site-members"
        self.find_element(By.LINK_TEXT, action, wait=0).click()
        self.assertElementWithText(By.CSS_SELECTOR, "body",
            "The workspace will be visible for site-members.")
        self.find_element(By.NAME, "form.button.Confirm", wait=0).click()
        self.assertElementWithText(By.CSS_SELECTOR, "body",
            "This workspace is only visible to site-members.")

        action = "Publish for site-members with public description"
        self.find_element(By.LINK_TEXT, action, wait=0).click()
        self.assertElementWithText(By.CSS_SELECTOR, "body",
            "The workspace will be visible for everyone on the web, but only site-members can see the conversation and material in it.")
        self.find_element(By.NAME, "form.button.Confirm", wait=0).click()
        self.assertElementWithText(By.CSS_SELECTOR, "body",
            "This workspace visible to site-members, the description is visible to everyone.")

        action = "Publish to the web"
        self.find_element(By.LINK_TEXT, action,
            wait=0).click()
        self.assertElementWithText(By.CSS_SELECTOR, "body",
            "The workspace will be visible for everyone on the web.")
        self.find_element(By.NAME, "form.button.Confirm", wait=0).click()
        self.assertElementWithText(By.CSS_SELECTOR, "body",
            "This workspace is visible to everyone.")

        action = "Retract from public"
        self.find_element(By.LINK_TEXT, action,
            wait=0).click()
        self.assertElementWithText(By.CSS_SELECTOR, "body",
            "The workspace will still be visible for site-members.")
        self.find_element(By.NAME, "form.button.Confirm", wait=0).click()
        self.assertElementWithText(By.CSS_SELECTOR, "body",
            "This workspace is only visible to site-members.")
Exemplo n.º 29
0
    def test_project_create_cancel(self):
        """
        Opens a project creation form but then cancels.
        """
        driver = self.driver
        login(driver, self.portal, username=testing.MANAGER,
            password=testing.PASSWORD)
        challenge_url = self.challenge.absolute_url()
        open(driver, challenge_url)
        self.find_element_by_text("Create Project").click()

        # wait while the page loads
        WebDriverWait(driver, self.implicitly_wait).until(
            lambda x: self.driver.current_url != challenge_url)

        draft_url = self.driver.current_url

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

        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)

        # wait while the page loads
        WebDriverWait(driver, self.implicitly_wait).until(
            lambda x: self.driver.current_url != draft_url)

        self.assertEqual(self.driver.current_url, challenge_url,
                         u"We should be sent back to where we came from after "
                         u"canceling, but we're not.")

        # make shure that the draft is actually deleted
        open(driver, draft_url)
        self.assertElementWithText(By.ID, "page-title",
                                   u"This page does not seem to exist…")
Exemplo n.º 30
0
 def test_ws_create_missing_input(self):
     """
     Attempts to create a workspace with some mandatory fields empty.
     The creation shouldn't be successful.
     """
     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()
     driver.find_element_by_id("form-widgets-title").clear()
     self.find_elements_by_text("Next")[-1].click()
     self.find_element_by_text("Next").click()
     self.find_element(By.CSS_SELECTOR, "input[value='Save']", wait=0).click()
     portalMessage = self.find_element_with_text("Required input is missing")
     assert portalMessage.is_displayed()
Exemplo n.º 31
0
    def test_basic_deco(self):

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

        layers.login(selenium, portal)