栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions

driver = webdriver.Chrome()
# 隐式等待: 会等待页面加载完成,最长等待10秒
# driver.implicitly_wait(10)

driver.get("http://www.baidu.com")

driver.find_element(By.ID, "s-top-loginbtn").click()

# 强制等待:
# sleep(3)

# 显示等待:针对某一个/一类元素,每隔0.5秒检查一次,直到这个元素满足条件, 继续往后执行,最长等待30秒时间
wait = WebDriverWait(driver, 30)
# 期望元素存在,但是不一定可见
# (By.ID, "TANGRAM__PSP_11__userName") 通过id查找元素:作为元组传入presence_of_element_located
# wait.until(expected_conditions.presence_of_element_located((By.ID, "TANGRAM__PSP_11__userName")))
# 期望所有元素存在
wait.until(expected_conditions.presence_of_all_elements_located((By.ID, "TANGRAM__PSP_11__userName")))
# 只有有元素可见
# wait.until(expected_conditions.visibility_of_any_elements_located((By.ID, "TANGRAM__PSP_11__userName")))
# 所有元素可见
# wait.until(expected_conditions.visibility_of_all_elements_located((By.ID, "TANGRAM__PSP_11__userName")))
# 单个元素可见
# wait.until(expected_conditions.visibility_of_element_located((By.ID, "TANGRAM__PSP_11__userName")))

driver.find_element(By.ID, "TANGRAM__PSP_11__userName").send_keys("username")
































































转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1018096.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号