def __init__(self, owner, locatordict={}):
        super(ResourcesNewAuthorsForm,self).__init__(owner,locatordict)

        # load hub's classes
        ResourcesNewAuthorsForm_Locators = self.load_class('ResourcesNewAuthorsForm_Locators')
        ResourcesNewAuthorsAuthorsForm = self.load_class('ResourcesNewAuthorsAuthorsForm')
        ResourcesNewAuthorsAuthorsList = self.load_class('ResourcesNewAuthorsAuthorsList')

        # update this object's locator
        self.locators.update(ResourcesNewAuthorsForm_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.group      = Select(self,{'base':'group'})
        self.access     = Select(self,{'base':'access'})

        self.authorform = IframeWrap(
                            ResourcesNewAuthorsAuthorsForm(
                                self,{'base':'authorsform'}),
                            ['authorsframe'])

        self.authorlist = IframeWrap(
                            ResourcesNewAuthorsAuthorsList(
                                self,{'base':'authorslist'}),
                            ['authorsframe'])

        self.submit     = Button(self,{'base':'submit'})

        self.fields = ['group','access']

        # update the component's locators with this objects overrides
        self._updateLocators()
class HubUCourseManageEmailForm(BasePageWidget):
    """hub u course manager email"""

    def __init__(self,owner,locatordict={}):
        super(HubUCourseManageEmailForm,self).__init__(owner,locatordict)

        # load hub's classes
        HubUCourseManageEmailForm_Locators = self.load_class('HubUCourseManageEmailForm_Locators')

        # update this object's locator
        self.locators.update(HubUCourseManageEmailForm_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.discard      = Link(self,{'base':'discard'})
        self.toaddr       = TextAC(self,{'base':'to',
                                         'aclocatorid':'toac',
                                         'choicelocatorid':'toacchoices',
                                         'tokenlocatorid':'toactoken',
                                         'deletelocatorid':'toacdelete'})
        self.fromaddr     = TextReadOnly(self,{'base':'from'})
        self.replyto      = TextReadOnly(self,{'base':'replyto'})
        self.template     = Select(self,{'base':'template'})
        self.subject      = TextReadOnly(self,{'base':'subject'})
        self.body         = TextReadOnly(self,{'base':'body'})
        self.submit       = Button(self,{'base':'submit'})

        # update the component's locators with this objects overrides
        self._updateLocators()


    def _checkLocators(self,widgets=None,cltype=''):

        # to see all of the widgets, you need to choose a template first
        options = self.template.options()
        self.template.choose(options[0])
        super(HubUCourseManageEmailForm,self)._checkLocators(widgets,cltype)


    def send_email(self,tolist,templateName):
        """send an email to the addresses in tolist using the template templateName"""

        if tolist != None:
            self.toaddr.value = tolist
        if templateName != None:
            self.template.value = templateName
        self.submit.click()
Пример #3
0
class ResourcesNewReviewForm(FormBase):
    def __init__(self, owner, locatordict={}):
        super(ResourcesNewReviewForm,self).__init__(owner,locatordict)

        # load hub's classes
        ResourcesNewReviewForm_Locators = self.load_class('ResourcesNewReviewForm_Locators')

        # update this object's locator
        self.locators.update(ResourcesNewReviewForm_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.authorization  = Checkbox(self,{'base':'authorization'})
        self.license        = Select(self,{'base':'license'})
        self.preview        = TextReadOnly(self,{'base':'preview'})

        self.fields = ['authorization','license']

        # update the component's locators with this objects overrides
        self._updateLocators()


    def get_license_types(self):
        """return the license types from the dropdown menu"""

        return self.license.options()


    def get_license_preview(self):
        """retrieve the license preview text"""

        return self.preview.value
    def __init__(self, owner, locatordict={}):
        super(HubUCourseMembershipListing,self).__init__(owner,locatordict)

        # load hub's classes
        HubUCourseMembershipListing_Locators = self.load_class('HubUCourseMembershipListing_Locators')
        HubUCourseMembershipListingMemberRow = self.load_class('HubUCourseMembershipListingMemberRow')
        HubUCourseMembershipListingDetailRow = self.load_class('HubUCourseMembershipListingDetailRow')

        # update this object's locator
        self.locators.update(HubUCourseMembershipListing_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.member_row    = HubUCourseMembershipListingMemberRow(self,{'base':'enrollee_row'})
        self.detail_row    = HubUCourseMembershipListingDetailRow(self,{'base':'detail_row'})
        self.action        = Select(self,{'base':'action'})
        self.action_submit = Button(self,{'base':'action_submit'})
        self.get_enroll    = Link(self,{'base':'get_enroll'},self._onClick)
        self.export_enroll = Link(self,{'base':'export_enroll'})
        self.members       = TextReadOnly(self,{'base':'members'})
        self.total         = TextReadOnly(self,{'base':'total'})

        self.member_data  = {}

        # update the component's locators with this objects overrides
        self._updateLocators()
    def __init__(self,owner,locatordict={}):
        super(HubUCourseManageEmailForm,self).__init__(owner,locatordict)

        # load hub's classes
        HubUCourseManageEmailForm_Locators = self.load_class('HubUCourseManageEmailForm_Locators')

        # update this object's locator
        self.locators.update(HubUCourseManageEmailForm_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.discard      = Link(self,{'base':'discard'})
        self.toaddr       = TextAC(self,{'base':'to',
                                         'aclocatorid':'toac',
                                         'choicelocatorid':'toacchoices',
                                         'tokenlocatorid':'toactoken',
                                         'deletelocatorid':'toacdelete'})
        self.fromaddr     = TextReadOnly(self,{'base':'from'})
        self.replyto      = TextReadOnly(self,{'base':'replyto'})
        self.template     = Select(self,{'base':'template'})
        self.subject      = TextReadOnly(self,{'base':'subject'})
        self.body         = TextReadOnly(self,{'base':'body'})
        self.submit       = Button(self,{'base':'submit'})

        # update the component's locators with this objects overrides
        self._updateLocators()
    def __init__(self, owner, locatordict={}):
        super(MembersProfileEmployment,self).__init__(owner,locatordict)

        # load hub's classes
        MembersProfileEmployment_Locators = self.load_class('MembersProfileEmployment_Locators')

        # update this object's locator
        self.locators.update(MembersProfileEmployment_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.employment = Select(self,{'base':'employment'})
        self.access     = Select(self,{'base':'access'})

        # update the component's locators with this objects overrides
        self._updateLocators()
    def __init__(self, owner, locatordict={}):
        super(MembersProfileCitizenship,self).__init__(owner,locatordict)

        # load hub's classes
        MembersProfileCitizenship_Locators = self.load_class('MembersProfileCitizenship_Locators')

        # update this object's locator
        self.locators.update(MembersProfileCitizenship_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.coriginus   = Radio(self,{'Yes':'coriginus_yes','No':'coriginus_no'})
        self.corigin     = Select(self,{'base':'corigin'})
        self.access      = Select(self,{'base':'access'})

        # update the component's locators with this objects overrides
        self._updateLocators()
class MembersProfileCitizenship(MembersProfileElement):
    def __init__(self, owner, locatordict={}):
        super(MembersProfileCitizenship,self).__init__(owner,locatordict)

        # load hub's classes
        MembersProfileCitizenship_Locators = self.load_class('MembersProfileCitizenship_Locators')

        # update this object's locator
        self.locators.update(MembersProfileCitizenship_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.coriginus   = Radio(self,{'Yes':'coriginus_yes','No':'coriginus_no'})
        self.corigin     = Select(self,{'base':'corigin'})
        self.access      = Select(self,{'base':'access'})

        # update the component's locators with this objects overrides
        self._updateLocators()


    def value(self):
        """return a dictionary with the values of coriginus, corigin, and access"""

        return {'coriginus' : self.coriginus.value(),
                'corigin'   : self.corigin.value(),
                'access'    : self.access.value()}


    def update(self,coriginus=None,corigin=None,access=None):
        """update the values of coriginus, corigin, and access"""

        if coriginus != None:
            self.coriginus.value = coriginus
        if corigin != None:
            self.corigin.value = corigin
        if access != None:
            self.access.value = access
        self.save.click()
class MembersProfileOrganization(MembersProfileElement):
    def __init__(self, owner, locatordict={}):
        super(MembersProfileOrganization,self).__init__(owner,locatordict)

        # load hub's classes
        MembersProfileOrganization_Locators = self.load_class('MembersProfileOrganization_Locators')

        # update this object's locator
        self.locators.update(MembersProfileOrganization_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.organization   = Select(self,{'base':'organization'})
        self.orgtext        = Text(self,{'base':'orgtext'})
        self.access         = Select(self,{'base':'access'})

        # update the component's locators with this objects overrides
        self._updateLocators()


    def value(self):
        """return a dictionary of the organization, orgtext, and access values"""

        return {'organization' : self.organization.value(),
                'orgtext'      : self.orgtext.value(),
                'access'       : self.access.value()}


    def update(self,organization=None,orgtext=None,access=None):
        """update the organization, orgtext, and access values"""

        if organization != None:
            self.organization.value = organization
        if orgtext != None:
            self.orgtext.value = orgtext
        if access != None:
            self.access.value = access
        self.save.click()
    def author_role(self,author,role=None):
        """adjust the role for an author, returning the old role"""

        rowEle = self._get_author_row(author)
        roleEle = self.find_element(self.locators['role'],rowEle)

        #FIXME: shenanigans begin
        roleid = roleEle.get_attribute('id')
        key = "roleid-%s" % (roleid)
        self.locators[key] = "css=#%s" % (roleid)
        obj = Select(self,{'base':key})
        obj.detach_from_owner()
        #FIXME: shenanigans end

        oldrole = obj.selected()
        if role:
            obj.value = role
            # click the "save changes" button
            self.submit.click()
        del obj
        del self.locators[key]
        return oldrole
Пример #11
0
class MembersProfileEmployment(MembersProfileElement):
    def __init__(self, owner, locatordict={}):
        super(MembersProfileEmployment,self).__init__(owner,locatordict)

        # load hub's classes
        MembersProfileEmployment_Locators = self.load_class('MembersProfileEmployment_Locators')

        # update this object's locator
        self.locators.update(MembersProfileEmployment_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.employment = Select(self,{'base':'employment'})
        self.access     = Select(self,{'base':'access'})

        # update the component's locators with this objects overrides
        self._updateLocators()


    def value(self):
        """return a dictionary with employment and access values"""

        return {'employment' : self.employment.value(),
                'access' : self.access.value()}


    def update(self,employment=None,access=None):
        """update the employment and access values"""

        if employment != None:
            self.employment.value = employment
        if access != None:
            self.access.value = access
        self.save.click()
class MembersProfileMailPreference2(MembersProfileElement):
    def __init__(self, owner, locatordict={}):
        super(MembersProfileMailPreference2,self).__init__(owner,locatordict)

        # load hub's classes
        MembersProfileMailPreference_Locators = self.load_class('MembersProfileMailPreference_Locators')

        # update this object's locator
        self.locators.update(MembersProfileMailPreference_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.mailpreference = Select(self,{'base':'mailpref'})
        self.access         = Select(self,{'base':'access'})

        # update the component's locators with this objects overrides
        self._updateLocators()


    def value(self):
        """return a dictionary of the mailpreference and access values"""

        return {'mailpreference' : self.mailpreference.value(),
                'access'         : self.access.value()}


    def update(self,mailpreference=None,access=None):
        """update the mailpreference and access values"""

        if mailpreference != None:
            self.mailpreference.value = mailpreference
        if access != None:
            self.access.value = access
        self.save.click()
    def __init__(self, owner, locatordict={}):
        super(MembersProfileMailPreference1,self).__init__(owner,locatordict)

        # load hub's classes
        MembersProfileMailPreference_Locators = self.load_class('MembersProfileMailPreference_Locators')

        # update this object's locator
        self.locators.update(MembersProfileMailPreference_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.mailpreference = Radio(self,{'Yes':'mail_yes','No':'mail_no'})
        self.access         = Select(self,{'base':'access'})

        # update the component's locators with this objects overrides
        self._updateLocators()
Пример #14
0
    def __init__(self, owner, locatordict={}):
        super(ResourcesNewReviewForm,self).__init__(owner,locatordict)

        # load hub's classes
        ResourcesNewReviewForm_Locators = self.load_class('ResourcesNewReviewForm_Locators')

        # update this object's locator
        self.locators.update(ResourcesNewReviewForm_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.authorization  = Checkbox(self,{'base':'authorization'})
        self.license        = Select(self,{'base':'license'})
        self.preview        = TextReadOnly(self,{'base':'preview'})

        self.fields = ['authorization','license']

        # update the component's locators with this objects overrides
        self._updateLocators()
Пример #15
0
class MembersProfileEmail(MembersProfileElement):
    def __init__(self, owner, locatordict={}):
        super(MembersProfileEmail,self).__init__(owner,locatordict)

        # load hub's classes
        MembersProfileEmail_Locators = self.load_class('MembersProfileEmail_Locators')

        # update this object's locator
        self.locators.update(MembersProfileEmail_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.email          = Text(self,{'base':'email'})
        self.confirmemail   = Text(self,{'base':'confirmemail'})
        self.access         = Select(self,{'base':'access'})

        # update the component's locators with this objects overrides
        self._updateLocators()


    def value(self):
        """return a dictionary of email, confirmemail, and access values"""

        return {'email'         : self.email.value(),
                'confirmemail'  : self.confirmemail.value(),
                'access'        : self.access.value()}


    def update(self,email=None,confirmemail=None,access=None):
        """update values for email, confirmemail, and access values"""

        if email != None:
            self.email.value = email
        if confirmemail != None:
            self.confirmemail.value = confirmemail
        if access != None:
            self.access.value = access
        self.save.click()
Пример #16
0
class MembersProfileInterests(MembersProfileElement):
    def __init__(self, owner, locatordict={}):
        super(MembersProfileInterests,self).__init__(owner,locatordict)

        # load hub's classes
        MembersProfileInterests_Locators = self.load_class('MembersProfileInterests_Locators')

        # update this object's locator
        self.locators.update(MembersProfileInterests_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.interests   = TextAC(self,{'base':'interests',
                                        'aclocatorid':'interestsac',
                                        'choicelocatorid':'interestsacchoices',
                                        'tokenlocatorid':'interestsactoken',
                                        'deletelocatorid':'interestsacdelete'})
        self.access      = Select(self,{'base':'access'})

        # update the component's locators with this objects overrides
        self._updateLocators()


    def value(self):
        """return a dictionary of the interests and access values"""

        return {'interests' : self.interests.value(),
                'access'    : self.access.value()}


    def update(self,interests=None,access=None):
        """update the value of the interests and access values"""

        if interests != None:
            self.interests.value = interests
        if access != None:
            self.access.value = access
        self.save.click()
Пример #17
0
    def __init__(self, owner, locatordict={}):
        super(ListPageNavBase, self).__init__(owner, locatordict)

        # load hub's classes
        # ListPageNavBase_Locators = self.load_class('ListPageNavBase_Locators')
        ListPageNavBase_Locators = ListPageNavBase_Locators_Base

        # update this object's locator
        self.locators.update(ListPageNavBase_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.limit = Select(self, {"base": "limit"})
        self.counts = TextReadOnly(self, {"base": "counts"})
        self.current_page = TextReadOnly(self, {"base": "currentpage"})

        self._pagenavnames = []

        # update the component's locators with this objects overrides
        self._updateLocators()
Пример #18
0
    def __init__(self, owner, locatordict={}):
        super(MembersProfileInterests,self).__init__(owner,locatordict)

        # load hub's classes
        MembersProfileInterests_Locators = self.load_class('MembersProfileInterests_Locators')

        # update this object's locator
        self.locators.update(MembersProfileInterests_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.interests   = TextAC(self,{'base':'interests',
                                        'aclocatorid':'interestsac',
                                        'choicelocatorid':'interestsacchoices',
                                        'tokenlocatorid':'interestsactoken',
                                        'deletelocatorid':'interestsacdelete'})
        self.access      = Select(self,{'base':'access'})

        # update the component's locators with this objects overrides
        self._updateLocators()
Пример #19
0
class MembersProfileBiography(MembersProfileElement):
    def __init__(self, owner, locatordict={}):
        super(MembersProfileBiography,self).__init__(owner,locatordict)

        # load hub's classes
        MembersProfileBiography_Locators = self.load_class('MembersProfileBiography_Locators')

        # update this object's locator
        self.locators.update(MembersProfileBiography_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.biography   = TextArea(self,{'base':'biography'})
        self.access      = Select(self,{'base':'access'})

        # update the component's locators with this objects overrides
        self._updateLocators()


    def value(self):
        """return a dictionary with the biography and access value settings"""

        return {'biography' : self.biography.value(),
                'access'    : self.access.value()}


    def update(self,biography=None,access=None):
        """update the biography and access settings"""

        if biography != None:
            self.biography.value = biography
        if access != None:
            self.access.value = access
        self.save.click()
Пример #20
0
class ResourcesNewAuthorsForm(BasePageWidget):
    def __init__(self, owner, locatordict={}):
        super(ResourcesNewAuthorsForm,self).__init__(owner,locatordict)

        # load hub's classes
        ResourcesNewAuthorsForm_Locators = self.load_class('ResourcesNewAuthorsForm_Locators')
        ResourcesNewAuthorsAuthorsForm = self.load_class('ResourcesNewAuthorsAuthorsForm')
        ResourcesNewAuthorsAuthorsList = self.load_class('ResourcesNewAuthorsAuthorsList')

        # update this object's locator
        self.locators.update(ResourcesNewAuthorsForm_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.group      = Select(self,{'base':'group'})
        self.access     = Select(self,{'base':'access'})

        self.authorform = IframeWrap(
                            ResourcesNewAuthorsAuthorsForm(
                                self,{'base':'authorsform'}),
                            ['authorsframe'])

        self.authorlist = IframeWrap(
                            ResourcesNewAuthorsAuthorsList(
                                self,{'base':'authorslist'}),
                            ['authorsframe'])

        self.submit     = Button(self,{'base':'submit'})

        self.fields = ['group','access']

        # update the component's locators with this objects overrides
        self._updateLocators()


    def get_groups(self):

        return self.group.options()


    def get_access_levels(self):

        return self.access.options()


    def populate_form(self, data):

        for k,v in data.items():
            if v is None:
                continue
            if not k in self.fields:
                # bail, the key is not a field
                raise ValueError("invalid form field: %s" % (k))
            # find the widget in the object's dictionary and set its value
            widget = getattr(self,k)
            widget.value = v


    def submit_form(self,data):

        self.populate_form(data)
        return self.submit.click()

    def populate_authors_form(self,data):

        return self.authorform.populate_form(data)


    def submit_authors_form(self,data):

        return self.authorform.submit_form(data)


    def get_authors(self):
        """return a list of authors"""

        return self.authorlist.get_authors()


    def author_role(self,author,role=None):
        """adjust an author's role"""

        return self.authorlist.author_role(author,role)


    def move_author_up(self,author):
        """increase an author's position"""

        return self.authorlist.move_author_up(author)


    def move_author_down(self,author):
        """decrease an author's position"""

        return self.authorlist.move_author_down(author)


    def delete_author(self,author):
        """remove an author from the list"""

        return self.authorlist.delete_author(author)


    def author_organization(self,author,org=None):
        """set an author's organization"""

        return self.authorlist.author_organization(author,org)
class HubUCourseMembershipListing(BasePageWidget):
    def __init__(self, owner, locatordict={}):
        super(HubUCourseMembershipListing,self).__init__(owner,locatordict)

        # load hub's classes
        HubUCourseMembershipListing_Locators = self.load_class('HubUCourseMembershipListing_Locators')
        HubUCourseMembershipListingMemberRow = self.load_class('HubUCourseMembershipListingMemberRow')
        HubUCourseMembershipListingDetailRow = self.load_class('HubUCourseMembershipListingDetailRow')

        # update this object's locator
        self.locators.update(HubUCourseMembershipListing_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.member_row    = HubUCourseMembershipListingMemberRow(self,{'base':'enrollee_row'})
        self.detail_row    = HubUCourseMembershipListingDetailRow(self,{'base':'detail_row'})
        self.action        = Select(self,{'base':'action'})
        self.action_submit = Button(self,{'base':'action_submit'})
        self.get_enroll    = Link(self,{'base':'get_enroll'},self._onClick)
        self.export_enroll = Link(self,{'base':'export_enroll'})
        self.members       = TextReadOnly(self,{'base':'members'})
        self.total         = TextReadOnly(self,{'base':'total'})

        self.member_data  = {}

        # update the component's locators with this objects overrides
        self._updateLocators()


    def update_enrollment(self):
        """click the update enrollment link"""

        self.get_enroll.click()


    def select_imported(self):
        """check the checkboxes of all imported course members"""

        count = 0
        imported_cbs = self.find_elements(self.locators['imported_cb'])
        for cb in imported_cbs:
            cb.click()
            count += 1
        return count


    def select_invited(self):
        """check the checkboxes of all invited course members"""

        count = 0
        invited_cbs = self.find_elements(self.locators['invited_cb'])
        for cb in invited_cbs:
            cb.click()
            count += 1
        return count


    def select_members(self):
        """check the checkboxes of all member course members"""

        count = 0
        member_cbs = self.find_elements(self.locators['member_cb'])
        for cb in member_cbs:
            cb.click()
            count += 1
        return count


    def get_footer_members_count(self):
        """retrieve the number of members in the group from the footer"""

        return self.members.value


    def get_footer_total_count(self):
        """retrieve the total number of people in the group from the footer"""

        return self.total.value


    def count_imported_rows(self):
        """retrieve the number of imported rows in the table"""

        return len(self.find_elements(self.locators['imported_row']))


    def count_invited_rows(self):
        """retrieve the number of invited rows in the table"""

        return len(self.find_elements(self.locators['invited_row']))


    def count_member_rows(self):
        """retrieve the number of member rows in the table"""

        return len(self.find_elements(self.locators['member_row']))


    def count_total_rows(self):
        """retrieve the number of total rows in the table"""

        return len(self.find_elements(self.locators['enrollee_row']))


    def prepare_to_send_email(self):
        """select the 'Send Email' action and goto the email page"""

        self.action.choose('Send Email')
        self.action_submit.click()


    def retrieve_members(self,save_cb=None, continue_cb=None, reverse=False):
        """return a list of member data from the table that match the specified criteria"""

        self.member_data = {}
        total = int(self.total.value)

        if reverse == False:
            start = 1
            end = total + 1
            step = 1
        else:
            start = total
            end = 1 - 1
            step = -1

        for index in xrange(start,end,step):
            didx = index*2
            midx = didx-1

            # FIXME: move the css code into locator file
            mlocator = self.locators['traversal_row'] % midx
            dlocator = self.locators['traversal_row'] % didx

            self.member_row.locator = mlocator
            name = self.member_row.name.text()

            # open the hidden detail row
            self.member_row.name.click()

            self.detail_row.locator = dlocator
            enroll_id = self.detail_row.enroll_id.value
            enroll_date = self.detail_row.enroll_date.value
            import_date = self.detail_row.import_date.value
            invite_sent = self.detail_row.invite_sent.value
            invite_accept = self.detail_row.invite_accept.value

            # close the detail row
            self.member_row.name.click()

            save = True
            cont = True

            mdata = {
                'name'          : name,
                'enroll_id'     : enroll_id,
                'enroll_date'   : enroll_date,
                'import_date'   : import_date,
                'invite_sent'   : invite_sent,
                'invite_accept' : invite_accept,
            }

            if continue_cb:
                cont = continue_cb(mdata)

            if not cont:
                break

            if save_cb:
                save = save_cb(mdata)

            if save:
                self.member_data[midx] = {
                    'name'          : name,
                    'enroll_id'     : enroll_id,
                    'enroll_date'   : enroll_date,
                    'import_date'   : import_date,
                    'invite_sent'   : invite_sent,
                    'invite_accept' : invite_accept,
                    '__mlocator__'  : mlocator,
                    '__dlocator__'  : dlocator,
                }

        return self.member_data


    def find_by_import_date(self,dtobj):
        """retrieve table data that matches the specified datetime object"""

        # date_object = datetime.strptime('Jun 1 2005  1:33PM', '%b %d %Y %I:%M%p')

        def callback(name, enroll_id, enroll_date, import_date, invite_sent, invite_accept):
            import_date_dt = datetime.strptime(import_date, '%b %d, %Y')
            return import_date_dt == dtobj

        return self.retrieve_members(callback)


    def select_retrieved_members(self):
        """check the 'select' box of members retrieved from the 'retrieve_members' method"""

        for [k,v] in self.member_data.items():
            self.member_row.locator = v['__mlocator__']
            self.member_row.cb_email.value = True


    def _onClick(self):
        """callback function for updating enrollments"""

        try:
            # wait for the page to refresh
            wait = WebDriverWait(self._browser, 30)
            wait.until(lambda browser :
                       browser.find_element_by_id("course-notice").is_displayed())
        except TimeoutException:
            # browser.save_screenshot_as_base64
            # self._browser.save_screenshot_as_file("need_help.submitted-1.png")
            raise TimeoutException("Timeout while waiting to retrieve new enrollments")

        # FIXME: check if the notice text is
        # "Enrollment Updates\n\nThere are no new enrollments or enrollment changes at this time."
        #e = self.find_element(self.locators['notice'])
        #ticket_number = e.text
        #return ticket_number
        return True
Пример #22
0
class ListPageNavBase(BasePageWidget):
    def __init__(self, owner, locatordict={}):
        super(ListPageNavBase, self).__init__(owner, locatordict)

        # load hub's classes
        # ListPageNavBase_Locators = self.load_class('ListPageNavBase_Locators')
        ListPageNavBase_Locators = ListPageNavBase_Locators_Base

        # update this object's locator
        self.locators.update(ListPageNavBase_Locators.locators)

        # update the locators with those from the owner
        self.update_locators_from_owner()

        # setup page object's components
        self.limit = Select(self, {"base": "limit"})
        self.counts = TextReadOnly(self, {"base": "counts"})
        self.current_page = TextReadOnly(self, {"base": "currentpage"})

        self._pagenavnames = []

        # update the component's locators with this objects overrides
        self._updateLocators()

    def goto_page_number(self, pagenumber):
        """click on a specific page in the pagination list"""

        # perform input validation
        pagenumber = int(pagenumber)

        if pagenumber < 1:
            raise IndexError(
                "pagenumber out of range: expected value\
                >= 1, received %s"
                % (pagenumber)
            )

        available_pages = self.get_link_page_numbers()
        if len(available_pages) == 0:
            if pagenumber != 1:
                raise IndexError("no pages available, pagenumber must be == 1")

        max_page_number = max([int(i) for i in available_pages])

        if pagenumber > max_page_number:
            raise IndexError(
                "pagenumber out of range: expected value\
                <= %i, received %d"
                % (max_page_number, pagenumber)
            )

        # click the page number link
        loctxt = self.locators["page"] % int(pagenumber)
        self.locators["_pagelink"] = loctxt
        page = Link(self, {"base": "_pagelink"})
        page.detach_from_owner()
        page.click()
        del page
        del self.locators["_pagelink"]

    def goto_page_relative(self, relation):
        """go to the start, end, previous, or next page"""

        if not relation in self._pagenavnames:
            raise ValueError("relation should be one of %s" % (self._pagenavnames))
        w = getattr(self, "%spage" % (relation))
        self._po.set_page_load_marker()
        w.click()
        # clicking navigation changes the page
        self._po.wait_for_page_to_load()

    def get_pagination_counts(self):
        """return a 3-tuple of the beginning shown, end shown, total resources"""

        countstxt = self.counts.value

        if countstxt.strip() == "No records found":
            return (0, 0, 0)

        pattern = re.compile("Results (\d+) - (\d+) of (\d+)")
        (beginshown, endshown, total) = pattern.match(countstxt).groups()
        return (int(beginshown), int(endshown), int(total))

    def display_limit(self, limit=None):
        """return the limit of the items shown"""

        if limit:
            self.limit.value = str(limit)
            # after changing the limit, the page refreshes
            self.limit.wait_until_present()
        return self.limit.value

    def get_current_page_number(self):
        """return the current page number"""

        return self.current_page.value

    def get_link_page_numbers(self):
        """return a list of the page numbers that are links"""

        pagelinks = self.find_elements_in_owner(self.locators["pagelinks"])
        pagenames = []
        for page in pagelinks:
            pagenames.append(page.text)
        return pagenames

    def relation_exists(self, relation):
        """check if the start, end, prev, next relation is in the html"""

        if not relation in self._pagenavnames:
            raise ValueError("relation should be one of %s" % (self._pagenavnames))
        w = getattr(self, "%spage" % (relation))
        return w.is_present()

    def relation_displayed(self, relation):
        """check if the start, end, prev, next relation is clickable"""

        if not relation in self._pagenavnames:
            raise ValueError("relation should be one of %s" % (self._pagenavnames))
        w = getattr(self, "%spage" % (relation))
        return w.is_displayed()