[python]代码库
from selenium import webdriver
from selenium.webdriver.common.by import By # 定位器是一种抽象的查询语言,用By 对象表示
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC # 。在隐式等待中,DOM 触发的状态是用expected_conditions 定义的
# WebDriverWait 和expected_conditions组合构成了Selenium 的隐式等待
driver = webdriver.PhantomJS(executable_path='F:\\Program Files\\phantomjs-2.1.1-windows\\bin\\phantomjs')
driver.get("http://pythonscraping.com/pages/javascript/ajaxDemo.html")
try:
element = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.ID,"loadedButton")))
finally:
print(driver.find_element_by_id("content").text)
driver.close()
[代码运行效果截图]
by: 发表于:2017-09-19 09:42:46 顶(0) | 踩(0) 回复
??
回复评论