当前位置: 首页>>代码示例>>Python>>正文


Python Link.get_attribute方法代码示例

本文整理汇总了Python中hubcheck.pageobjects.basepageelement.Link.get_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python Link.get_attribute方法的具体用法?Python Link.get_attribute怎么用?Python Link.get_attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hubcheck.pageobjects.basepageelement.Link的用法示例。


在下文中一共展示了Link.get_attribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ResourcesToolScreenshotUploadRow

# 需要导入模块: from hubcheck.pageobjects.basepageelement import Link [as 别名]
# 或者: from hubcheck.pageobjects.basepageelement.Link import get_attribute [as 别名]
class ResourcesToolScreenshotUploadRow(ItemListItem):

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

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

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

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

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

        # setup page object's components
        self.edit     = Link(self,{'base':'edit'})
        self.img_edit = Link(self,{'base':'img_edit'})
        self.delete   = Link(self,{'base':'delete'})

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


    def value(self):
        """return the title"""

        return self.img_edit.get_attribute('title')
开发者ID:codedsk,项目名称:hubcheck,代码行数:30,代码来源:resources_tool_screenshot_upload_row.py

示例2: Header3

# 需要导入模块: from hubcheck.pageobjects.basepageelement import Link [as 别名]
# 或者: from hubcheck.pageobjects.basepageelement.Link import get_attribute [as 别名]
class Header3(Header):
    """
    represents header on hubs where the username and my account links
    lead to the my account/dashboard page, and there is no profile link.
    generally found in older templates. here we use the username link
    to get the account number
    """

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

        # setup page object's additional components
        self.username       = Link(self,{'base':'username'})

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


    def _checkLocatorsLoggedIn(self):

        widgets = [self.logout,self.myaccount,self.username]
        self._checkLocators(widgets=widgets,cltype='LoggedIn')


    def goto_username(self):
        """click the username link to go to the member's account page"""

        return self.username.click()


    def get_account_number(self):
        """return the user's account number based on the "Username" link"""

        url = self.username.get_attribute('href')
        if not url:
            raise RuntimeError("link '%s' has no href" % (self.username.locator))

        path = urlparse.urlsplit(url)[2]
        if not path:
            raise RuntimeError("url '%s' has no path" % (url))

        matches = re.search("/members/(\d+)",path)
        if matches is None:
            raise RuntimeError("path '%s' does not contain an account number" % (path))

        account_number = matches.group(1)

        return account_number
开发者ID:codedsk,项目名称:hubcheck,代码行数:50,代码来源:header.py

示例3: Header

# 需要导入模块: from hubcheck.pageobjects.basepageelement import Link [as 别名]
# 或者: from hubcheck.pageobjects.basepageelement.Link import get_attribute [as 别名]
class Header(BasePageWidget):
    def __init__(self, owner, locatordict={}):
        super(Header,self).__init__(owner,locatordict)

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

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

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

        # setup page object's components
        self.login          = Link(self,{'base':'login'})
        self.register       = Link(self,{'base':'register'})
        self.logout         = Link(self,{'base':'logout'})
        self.myaccount      = Link(self,{'base':'myaccount'})

        # self.search    = Search(self,{'base':'search'})

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


    def _checkLocatorsLoggedOut(self):

        widgets = [self.login,self.register]
        self._checkLocators(widgets=widgets,cltype='LoggedOut')


    def _checkLocatorsLoggedIn(self):

        widgets = [self.logout,self.myaccount]
        self._checkLocators(widgets=widgets,cltype='LoggedIn')


    def goto_login(self):
        """click the login link"""

        return self.login.click()


    def goto_register(self):
        """click the register link"""

        return self.register.click()


    def goto_logout(self):
        """click the logout link"""

        self.logout.click()
        message = 'logout button visible while trying to logout'
        self.logout.wait_until_invisible(message)
        return


    def goto_myaccount(self):
        """click the link to go to the member's myaccount page"""

        return self.myaccount.click()


    def is_logged_in(self):
        """check if user is logged in, returns True or False"""

        return self.logout.is_displayed()


    def get_account_number(self):
        """return the user's account number based on the "My Account" url"""

        url = self.myaccount.get_attribute('href')
        if not url:
            raise RuntimeError("link '%s' has no href" % (self.myaccount.locator))

        path = urlparse.urlsplit(url)[2]
        if not path:
            raise RuntimeError("url '%s' has no path" % (url))

        matches = re.search("/members/(\d+)",path)
        if matches is None:
            raise RuntimeError("path '%s' does not contain an account number" % (path))

        account_number = matches.group(1)

        return account_number
开发者ID:codedsk,项目名称:hubcheck,代码行数:90,代码来源:header.py

示例4: Header2

# 需要导入模块: from hubcheck.pageobjects.basepageelement import Link [as 别名]
# 或者: from hubcheck.pageobjects.basepageelement.Link import get_attribute [as 别名]

#.........这里部分代码省略.........
        return self._links


    def goto_options_item(self,link):
        """this function does selenium specific stuff"""

        if not link in self._links:
            raise ValueError("invalid link name: '%s'",link)

        # hover mouse over the account toolbar to expand it
        # move the mouse to the correct link and click it

        menu = self.find_element(self.locators['acctbase'])
        loc = self.locators[link]
        menu_item = self.find_element(loc)

        self.logger.debug("moving mouse over account dropdown")
        self.logger.debug("clicking drowdown menu option '%s': %s" % (link,loc))

        actionProvider = ActionChains(self.owner._browser)\
                         .move_to_element(menu)\
                         .move_to_element(menu_item)\
                         .click()
        actionProvider.perform()


    def goto_login(self):

        return self.login.click()


    def goto_register(self):

        return self.register.click()


    def goto_logout(self):

        lockey = 'logout'
        self.goto_options_item(lockey)
        # wait until the element is no longer visible (ie. the menu has closed)
        # before proceeding to the next task
        loc = self.locators[lockey]
        self.wait_until_not_present(locator=loc)


    def goto_myaccount(self):

        # deprecated function, use goto_dashboard() instead
        return self.goto_options_item('dashboard')


    def goto_dashboard(self):

        return self.goto_options_item('dashboard')


    def goto_messages(self):

        return self.goto_options_item('messages')


    def goto_profile(self):

        return self.goto_options_item('profile')


    def is_logged_in(self):
        """check if user is logged in, returns True or False"""

        # return not self.login.is_displayed()
        return self.logout.is_present()

    def get_account_number(self):
        """return the user's account number based on the "Username" url"""

        url = None

        # use dashboard instead of details because some hubs (like catalyzecare)
        # don't make details a link.
        url = self.dashboard.get_attribute('href')

        if url is None:
            raise RuntimeError("link '%s' has no href" \
                % (self.details.locators['base']))

        path = urlparse.urlsplit(url)[2]
        if not path:
            raise RuntimeError("url '%s' has no path" % (url))

        # the url looks something like:
        # https://hubname.org/members/1234/dashboard
        matches = re.search("/members/(\d+)",path)
        if matches is None:
            raise RuntimeError("path '%s' does not contain an account number" \
                % (path))

        account_number = matches.group(1)

        return account_number
开发者ID:codedsk,项目名称:hubcheck,代码行数:104,代码来源:header.py

示例5: MembersDashboardMySessionsItem

# 需要导入模块: from hubcheck.pageobjects.basepageelement import Link [as 别名]
# 或者: from hubcheck.pageobjects.basepageelement.Link import get_attribute [as 别名]

#.........这里部分代码省略.........
        return self.title.text()


    def toggle_slide(self):
        """open or close the session item slide down"""

        check_invisible = self.resume.is_displayed()

        self.title.click()

        if check_invisible:
            message = 'while closing toggle, waiting for resume to disappear'
            self.resume.wait_until_invisible(message)
        else:
            message = 'while closing toggle, waiting for resume to appear'
            self.resume.wait_until_visible(message)

        return


    def is_slide_open(self):
        """check if the session item slide down is open"""

        return (self.title.is_displayed() and self.resume.is_displayed())


    def get_last_accessed(self):
        """return the last accessed time stamp as a string and datetime object"""

        at_text = self.access_time.value
        dt_text = re.sub(r'Last Accessed:\s+','',at_text,flags=re.IGNORECASE)
        # dt_text should look something like this:
        # October 12, 2013 @ 12:44am
        dt = datetime.datetime.strptime(dt_text,'%B %d, %Y @ %I:%M%p')

        return (dt_text,dt)


    def get_session_owner(self):
        """return the session owner"""

        owner_text = None
        if self.session_owner.is_displayed():
            owner_text = self.session_owner.text()
        return owner_text


    def get_session_number(self):
        """return the session number based on the url for the "open" link"""

        self.logger.debug('retrieving session number')

        snre = re.compile(r'=([0-9]+)')
        href = self.resume.get_attribute('href')

        self.logger.debug('href = %s' % (href))

        match =  snre.search(href)
        if match:
            session_number = int(match.group(1))
        else:
            session_number = None

        self.logger.debug('session_number = %d' % (session_number))

        return session_number


    def resume_session(self):
        """open this session"""

        return self.resume.click()


    def terminate_session(self,confirm=True):
        """terminate this session"""

        self.terminate.click()
        alert = self._browser.switch_to_alert()
        if confirm:
            self.logger.debug('accepting alert')
            alert.accept()
        else:
            self.logger.debug('dismissing alert')
            alert.dismiss()
        self._browser.switch_to_default_content()


    def disconnect_session(self,confirm=True):
        """disconnect from this shared session"""

        self.disconnect.click()
        alert = self._browser.switch_to_alert()
        if confirm:
            self.logger.debug('accepting alert')
            alert.accept()
        else:
            self.logger.debug('dismissing alert')
            alert.dismiss()
        self._browser.switch_to_default_content()
开发者ID:codedsk,项目名称:hubcheck,代码行数:104,代码来源:members_dashboard_my_sessions_item.py


注:本文中的hubcheck.pageobjects.basepageelement.Link.get_attribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。