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)


 
原文地址:https://www.cnblogs.com/angdh/p/11991967.html