本文整理汇总了Python中hubcheck.pageobjects.basepageelement.Link.is_present方法的典型用法代码示例。如果您正苦于以下问题:Python Link.is_present方法的具体用法?Python Link.is_present怎么用?Python Link.is_present使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hubcheck.pageobjects.basepageelement.Link
的用法示例。
在下文中一共展示了Link.is_present方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Header2
# 需要导入模块: from hubcheck.pageobjects.basepageelement import Link [as 别名]
# 或者: from hubcheck.pageobjects.basepageelement.Link import is_present [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
示例2: GroupsWikiArticle
# 需要导入模块: from hubcheck.pageobjects.basepageelement import Link [as 别名]
# 或者: from hubcheck.pageobjects.basepageelement.Link import is_present [as 别名]
class GroupsWikiArticle(BasePageWidget):
def __init__(self, owner, locatordict):
super(GroupsWikiArticle,self).__init__(owner,locatordict)
# load hub's classes
GroupsWikiArticle_Locators = self.load_class('GroupsWikiArticle_Locators')
TagsList = self.load_class('TagsList')
# update this object's locator
self.locators.update(GroupsWikiArticle_Locators.locators)
# update the locators with those from the owner
self.update_locators_from_owner()
# setup page object's components
self.pagetext = TextReadOnly(self,{'base':'pagetext'})
self.timestamp = TextReadOnly(self,{'base':'timestamp'})
self.tags = TagsList(self,{'base':'tags'})
self.authors = TextReadOnly(self,{'base':'authors'})
self.create = Link(self,{'base':'create'})
# update the component's locators with this objects overrides
self._updateLocators()
def _checkLocatorsWikiPage(self,widgets=None,cltype='WikiPage'):
widgets = [self.pagetext,self.timestamp,self.tags]
super(GroupsWikiArticle,self)._checkLocators(widgets,cltype)
def _checkLocatorsKnowledgeBase(self,widgets=None,cltype='KnowledgeBase'):
widgets = [self.pagetext,self.timestamp,self.tags,self.authors]
super(GroupsWikiArticle,self)._checkLocators(widgets,cltype)
def _checkLocatorsNewPage(self,widgets=None,cltype='NewPage'):
widgets = [self.create]
super(GroupsWikiArticle,self)._checkLocators(widgets,cltype)
def get_tags(self):
return self.tags.get_tags()
def click_tag(self,tagname):
return self.tags.click_tag(tagname)
def get_page_text(self):
return self.pagetext.value
def get_authors(self):
# e = self.find_element(self.locators['authors'])
# authortext = re.sub(r'by ','',e.text)
# authortext = re.sub(r', ',',',authortext)
# authorlist = authortext.split(',')
# return authorlist
authorlist = []
authorElements = self.find_elements(self.locators['authorlink'])
for authorElement in authorElements:
authorlist.append(authorElement.text)
return authorlist
def is_created(self):
return not self.create.is_present()
def create_page(self):
return self.create.click()
def download_attachment(self,attachment):
wikipagetext = self.find_element(self.locators['pagetext'])
links = self.find_elements(self.locators['links'],wikipagetext)
download_element = None
for link in links:
href = link.get_attribute('href')
if re.search(attachment,href):
download_element = link
break
else:
raise NoSuchFileAttachmentError(
"attachment not found on page: %s" % (attachment))
download_element.click()
# this should probably be called is_file_downloadable
# and is_file_attached, should just look to see if the
#.........这里部分代码省略.........