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


Python Browser.is_element_not_present_by_text方法代码示例

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


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

示例1: __init__

# 需要导入模块: from splinter import Browser [as 别名]
# 或者: from splinter.Browser import is_element_not_present_by_text [as 别名]
class ArloVideoDownloader:
  def __init__(self, verbose):
    from splinter import Browser
    self.browser = Browser("chrome")
    self.verbose = verbose

  def __del__(self):
    if self.verbose:
      return

    # Leave the browser open if this is running with Verbose option.
    if self.browser != None:
      self.browser.quit()

  def Login(self, account, password):
    self.browser.visit("https://arlo.netgear.com/#/login")
    self.browser.fill('userId', account)
    self.browser.fill('password', password)

    button = self.browser.find_by_id('loginButton')
    if button.is_empty():
      self.Debug("Cannot find loginButton.")
      return False

    button.click()

    self.WaitForPageUpdate()
    # Wait for page to load. This can take some time.
    if self.browser.is_element_not_present_by_text('Library', wait_time = cWaitingTimeForPageUpdate):
      return False
    else:
      return True

  def DownloadTodaysVideo(self):
    print "Logging in.."
    if not self.OpenYesterdayPage():
      self.Debug("Err> Cannot open library tab")
      return False

    print "Downloading Video.."
    self.IterateToDownloadAll()
    self.WaitForDownloading()

  def WaitForPageUpdate(self):
    self.Debug("Wait %d seconds.." % cWaitingTimeForPageUpdate)
    time.sleep(cWaitingTimeForPageUpdate)    

  def IterateToDownloadAll(self):
    self.SetSelectVideoMode()

    previews = self.browser.find_by_css('.timeline-record')
    
    # Go over for each video.
    # I didn't try to download all at once, because I couldn't
    # avoid the problem that Browser asking for a permission
    # to download multiple files at once.
    # So, download videos one by one
    previousButton = None
    for button in previews:
      if previousButton is not None:
        # Unselect last one.
        previousButton.click()

      # Select new one
      button.click()
      previousButton = button

      self.WaitForPageUpdate()
      self.PushDownload()

  def OpenYesterdayPage(self):    
    #https://arlo.netgear.com/#/calendar/201512/all/all/20151226/day
    # They have changed it! 2015/12/29
    #https://arlo.netgear.com/#/calendar/201512/20151228/day
    yesterday = self.GetYesterday()
    url = "https://arlo.netgear.com/#/calendar/%d%d/%d%d%d/day" % (
      yesterday.year, yesterday.month, yesterday.year, yesterday.month, yesterday.day)
    self.Debug("Visiting: %s" % url)

    # This breaks session! What should I do?
    self.browser.visit(url)
    self.WaitForPageUpdate()
    
    return not self.browser.is_element_not_present_by_text('Select')

  def SetSelectVideoMode(self):
    self.browser.find_by_text('Select').click()

  def GetYesterday(self):
    return datetime.datetime.now() - datetime.timedelta(hours=24)

  def PushDownload(self):
    # TODO: Can we change the download folder?
    buttons = self.browser.find_by_css('.download')
    buttons[0].click()
    pass

  def WaitForDownloading(self):
    # TODO: How can I know when all the downloading would be completed?
    time.sleep(cWaitingTimeForDownloadingToComplete)
#.........这里部分代码省略.........
开发者ID:Magoja,项目名称:arloBackup,代码行数:103,代码来源:arloBackup.py


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