Beispiel #1
0
    def value(self):
        """get the value of the captcha"""

        self.question = TextReadOnly(self.owner,self.locatordict)
        text = self.question.value
        self.question.detach_from_owner()
        return text
    def __init__(self, owner, locatordict={}):
        super(ToolsStatusApproveToolInfoForm,self).__init__(owner,locatordict)

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

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

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

        # setup page object's components
        self.tool_info          = Link(self,{'base':'tool_info'})
        self.title              = TextReadOnly(self,{'base':'title'})
        self.version            = TextReadOnly(self,{'base':'version'})
        self.version_edit       = Link(self,{'base':'version_edit'})
        self.description        = TextReadOnly(self,{'base':'description'})
        self.tool_access        = TextReadOnly(self,{'base':'tool_access'})
        self.code_access        = TextReadOnly(self,{'base':'code_access'})
        self.project_access     = TextReadOnly(self,{'base':'project_access'})
        self.screen_size        = TextReadOnly(self,{'base':'screen_size'})
        self.developers         = TextReadOnly(self,{'base':'developers'})
        self.authors            = TextReadOnly(self,{'base':'authors'})
        self.resource_preview   = Link(self,{'base':'resource_preview'})
        self.license_edit       = Link(self,{'base':'license_edit'})
        self.license            = TextReadOnly(self,{'base':'license'})
        self.approve            = Button(self,{'base':'approve'})


        # update the component's locators with this objects overrides
        self._updateLocators()
class ToolsStatusVersionListRow(ItemListItem):
    def __init__(self, owner, locatordict={},row_number=0):

        super(ToolsStatusVersionListRow,self)\
            .__init__(owner,locatordict,row_number)

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

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

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

        # setup page object's components
        self.version      = TextReadOnly(self,{'base':'version'})
        self.released     = TextReadOnly(self,{'base':'released'})
        self.subversion   = TextReadOnly(self,{'base':'subversion'})
        self.published    = TextReadOnly(self,{'base':'published'})
        self.edit         = Link(self,{'base':'edit'})

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


    def value(self):
        """return a dictionary of properties for this row"""

        published_classes = self.published.get_attribute('class')

        published = None
        if 'toolunpublished' in published_classes:
            published = False
        elif 'toolpublished' in published_classes:
            published = True

        properties = {
            'version'    : self.version.value,
            'released'   : self.released.value,
            'subversion' : self.subversion.value,
            'published'  : published,
        }

        return properties


    def goto_edit(self):

        self.edit.click()
    def __init__(self, owner, locatordict={}, row_number=0):

        super(ResourcesToolFileUploadRow,self).__init__(owner,locatordict,row_number)

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

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

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

        # setup page object's components
        self.name     = TextReadOnly(self,{'base':'name'})
        self.show     = Link(self,{'base':'show'},self._onClickShow)
        self.delete   = Link(self,{'base':'delete'},self._onClickDelete)

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

        super(ToolsStatusVersionListRow,self)\
            .__init__(owner,locatordict,row_number)

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

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

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

        # setup page object's components
        self.version      = TextReadOnly(self,{'base':'version'})
        self.released     = TextReadOnly(self,{'base':'released'})
        self.subversion   = TextReadOnly(self,{'base':'subversion'})
        self.published    = TextReadOnly(self,{'base':'published'})
        self.edit         = Link(self,{'base':'edit'})

        # update the component's locators with this objects overrides
        self._updateLocators()
Beispiel #6
0
class Captcha2(BasePageWidget):
    def __init__(self, owner, locatordict={}, refreshCB=None):
        super(Captcha2,self).__init__(owner,locatordict)

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

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

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

        # setup page object's components
        self.refreshCB   = refreshCB
        self.answer      = BasePageWidget(self,{'base':'captcha-answer'})

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


    @property
    def value(self):
        """get the value of the captcha"""

        self.question = TextReadOnly(self.owner,self.locatordict)
        text = self.question.value
        self.question.detach_from_owner()
        return text

    @value.setter
    def value(self, val):
        """set the value of the captcha"""

        if val:
            self.solve()


    def refresh(self):
        """refresh the captcha"""

        if self.refreshCB:
            self.refreshCB()
        else:
            self._browser.refresh()


    def solve(self):
        """solve the captcha"""

        handler = {
            'input' : Text,
            'select' : Select,
        }

        captchaInfo = os.path.join(hubcheck.conf.settings.data_dir,'captcha.json')
        with open(captchaInfo,'r') as f:
            captchadict = json.load(f)
        f.close()

        pattern = re.compile("Please answer the question:\nREQUIRED\n\n(.+)")
        count = 0
        solved = False

        while count < 10:
            count = count + 1

            # grab the captcha question
            t = self.value
            try:
                q = pattern.search(t).group(1)
            except:
                # yikes, no question text found!
                # refresh the browser and try again
                self.logger.debug("Could not parse question from CAPTCHA: %s" % (t))
                self.refresh()
                continue

            # have we seen this question before
            if captchadict.has_key(q) == False:
                # question not in dictionary
                # refresh the browser and try again
                self.logger.debug("Question not in dictionary: %s" % (q))
                self.refresh()
                continue

            # fill in the answer for the captcha
            self.answer.detach_from_owner()
            self.answer = handler[captchadict[q]['tag_name']](self,{'base':'captcha-answer'})
            self.answer.value = captchadict[q]['options'][captchadict[q]['answeridx']]
            solved = True
            break

        return solved
class ResourcesToolFileUploadRow(ItemListItem):

    def __init__(self, owner, locatordict={}, row_number=0):

        super(ResourcesToolFileUploadRow,self).__init__(owner,locatordict,row_number)

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

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

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

        # setup page object's components
        self.name     = TextReadOnly(self,{'base':'name'})
        self.show     = Link(self,{'base':'show'},self._onClickShow)
        self.delete   = Link(self,{'base':'delete'},self._onClickDelete)

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


    def _onClickShow(self):
        self.show.wait_until_invisible()


    def _onClickDelete(self):
        self.delete.wait_until_invisible()


    def rename(self,name):
        """rename the uploaded document"""
        # use action chains to double click on the name,
        # and fill in a new value
        # the documentation above the widget says the user
        # needs to double click, but it appears a single
        # click will work. it also says tab or enter
        # save, but i don't think these keys do anything
        e = self.name.wait_until_visible()
        ActionChains(self._browser)\
            .double_click(e)\
            .perform()

        t = Text(self,{'base':'rename_text'})
        s = Button(self,{'base':'rename_save'})

        t.wait_until_visible()
        t.value = name
        s.click()
        s.wait_until_not_present()

        del t
        del s


    def value(self):
        """return a dictionary with the name and size properties"""

        # show text looks like this:
        # <filename>, <size> <units>
        # simulink.jpg, 41.99 Kb
        size = self.show.text().split(',')[1].strip()

        return({'name':self.name.text(), 'size':size})
class ToolsStatusApproveToolInfoForm(BasePageWidget):
    def __init__(self, owner, locatordict={}):
        super(ToolsStatusApproveToolInfoForm,self).__init__(owner,locatordict)

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

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

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

        # setup page object's components
        self.tool_info          = Link(self,{'base':'tool_info'})
        self.title              = TextReadOnly(self,{'base':'title'})
        self.version            = TextReadOnly(self,{'base':'version'})
        self.version_edit       = Link(self,{'base':'version_edit'})
        self.description        = TextReadOnly(self,{'base':'description'})
        self.tool_access        = TextReadOnly(self,{'base':'tool_access'})
        self.code_access        = TextReadOnly(self,{'base':'code_access'})
        self.project_access     = TextReadOnly(self,{'base':'project_access'})
        self.screen_size        = TextReadOnly(self,{'base':'screen_size'})
        self.developers         = TextReadOnly(self,{'base':'developers'})
        self.authors            = TextReadOnly(self,{'base':'authors'})
        self.resource_preview   = Link(self,{'base':'resource_preview'})
        self.license_edit       = Link(self,{'base':'license_edit'})
        self.license            = TextReadOnly(self,{'base':'license'})
        self.approve            = Button(self,{'base':'approve'})


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


    def edit_tool_info(self):
        """
        edit the tool's information
        """

        self.tool_info.click()


    def edit_version(self):
        """
        edit the tool's version
        """

        self.version.click()


    def preview_resource_page(self):
        """
        navigate to the resource page preview
        """

        self.resource_preview.click()


    def edit_license(self):
        """
        edit the tool license
        """

        self.license_edit.click()


    def value(self):
        """
        return a summary of the widget
        """

        v = {'title' : self.title.value,
             'version' : self.version.value,
             'description' : self.description.value,
             'tool_access' : self.tool_access.value,
             'source_access' : self.source_access.value,
             'project_access' : self.project_access.value,
             'screen_size' : self.screen_size.value,
             'developers' : self.developers.value,
             'authors' : self.authors.value,
             'license' : self.license.value,
            }

        return v


    def approve_tool(self):
        """
        approve the tool's version, license, and info.
        """

        self.approve.click()