首页 > 编程语言 > 详细

Python--WebDriverWait+expected_conditions的一个应用

时间:2018-11-06 11:47:09      阅读:174      评论:0      收藏:0      [点我收藏+]
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as Wait
from selenium.webdriver.support import expected_conditions as Expect
‘‘‘
注意 expected_conditions 并不是一个类,而是一个文件,它下面有很多类,都是小写字母
‘‘‘
browser = webdriver.Chrome()
browser.get(http://www.tuniu.com/flight/intel/sha-sel)

Wait(browser,60).until(Expect.text_to_be_present_in_element((By.ID, "loadingStatus"),u"共搜索"))

flight_items =browser.find_elements_by_class_name("flight-item")
print(len(flight_items))
for flight_item in flight_items:
       flight_price_row =flight_item.find_element_by_class_name("flight-price-row")
       print(flight_price_row.get_attribute("data-no"))

 

Python--WebDriverWait+expected_conditions的一个应用

原文:https://www.cnblogs.com/chendezhen/p/9914296.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!