selenium完整例子


driver.get("https://www.booking.com")

//通過 xpath 等待input 元素 是否 加載出來, 最大等 60s
input_blno = WebDriverWait(driver, 60).until(
        EC.presence_of_element_located((By.XPATH, """//*[@id="search-stripe"]/table/input"""))
    )



//通過 xpath 定位 元素 ,點擊元素
the_butten = driver.find_element(By.XPATH, '//*[@id="ext-gen361"]/input')
the_butten.click()


//判斷頁面 是否 包含什么 內容
if 'DOCUMENT does not exist' in driver.page_source:
print "nononoon"
return None
//光標 移動 
//動態 找到 tr
t_d_butten = driver.find_element_by_xpath("""//*[@id="ext-gen46"]//table/tbody/tr[%s]/td[1]""" % (i + 1))
# 光標 移動到 目標位置
ActionChains(driver).move_to_element(t_d_butten).perform()
time.sleep(1)
# 點擊這一行
t_d_butten.click()
time.sleep(0.5)


 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM