本文整理汇总了Python中selenium.webdriver.support.ui.WebDriverWait.strip方法的典型用法代码示例。如果您正苦于以下问题:Python WebDriverWait.strip方法的具体用法?Python WebDriverWait.strip怎么用?Python WebDriverWait.strip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.ui.WebDriverWait
的用法示例。
在下文中一共展示了WebDriverWait.strip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findTopCommentAndTopNumber
# 需要导入模块: from selenium.webdriver.support.ui import WebDriverWait [as 别名]
# 或者: from selenium.webdriver.support.ui.WebDriverWait import strip [as 别名]
def findTopCommentAndTopNumber(browser, article, COMMENT_NUM_CRITERIA,VOTEUP_CRITERIA ):
resultDict = {}
print "inside disqus"
##browser.switch_to.frame("dsq-2")
try:
frame = WebDriverWait(browser, 130).until(EC.element_to_be_clickable((By.CSS_SELECTOR,"iframe#dsq-2")))
browser.switch_to.frame(frame)
except Exception:
print "#################### EXCEPTION fail to switch iframe"
return resultDict
comNum = 0
##.comment-count
try:
elm = WebDriverWait(browser, 30).until(EC.presence_of_element_located((By.CSS_SELECTOR,".comment-count")))
text = elm.text
print "Time Text %s" % text
if isinstance(text, basestring) and len(text) > 0:
numText = re.search( r'^\d+\s', text)
print "numText: %s" % numText.group()
try:
comNum = int(numText.group().strip())
except Exception:
print "**************EXCEPTION comment Number"
except Exception as e:
print "############################# EXCEPTION comment count %s" % e
if comNum < COMMENT_NUM_CRITERIA:
browser.switch_to.default_content();
return resultDict
##//a[@href='#disqus_thread']
##.dropdown-toggle
##try
##//a[@data-sort='popular']
try:
##xpath
##//a[@data-nav="conversation"]
##".dropdown-toggle"
WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH,"//a[@data-nav='conversation'][@data-toggle='dropdown']"))).click()
except Exception:
browser.switch_to.default_content();
print "############# EXCEPTION //a[@data-nav='conversation']"
return resultDict
try:
WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH,"//a[@data-sort='popular']"))).click()
except Exception as e:
print "################### EXCEPTION a[@data-sort='popular']"
browser.switch_to.default_content();
return resultDict
##a data-role="username"
print "TIME SLEEP"
time.sleep(3)
##.updatable.count
topCommentNumber = 0
try:
elm = WebDriverWait(browser, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR,".updatable.count")))
text = elm.text
if isinstance(text, basestring) and len(text) > 0:
try:
topCommentNumber = int(text)
except Exception as e:
print "############# EXCEPTION fail to convert ot number"
except Exception as e:
print "#######################EXCEPTION Comment Number"
if topCommentNumber < VOTEUP_CRITERIA:
print "RETURNING Small Number"
browser.switch_to.default_content();
return resultDict
##.post-message
"""BROWSER UI: LOAD COMMENTS"""
"""Old page links should be gone"""
topComment = ''
try:
topComment = WebDriverWait(browser, 5).until(EC.presence_of_element_located((By.CSS_SELECTOR,".post-message>p"))).text
topComment = articleUtil.truncatedStringForRow(topComment);
# for elm in elms[:]:
# topComment = topComment + ' ' + elm.text
except Exception as e:
print "NoSuchElementException /TimeoutException .content__dateline>time"
#.........这里部分代码省略.........