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)