本文整理汇总了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)
#.........这里部分代码省略.........