Python--WebDriverWait+expected_conditions的一个应用

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"))

 

posted @ 2018-11-06 11:28  划边逅  阅读(488)  评论(0编辑  收藏  举报