# 查找文本框输入文本
driver.find_element(By.CLASS_NAME,"nav-search-input").send_keys("i_cecream查找到了")
#查找到之后点击
driver.find_element(By.CLASS_NAME,"nav-search-btn").click()
time.sleep(30)
selenium4的解析。
client调用server之后调用browser
browser返回是否错误到server到client
browser到webdriver到client
元素定位
常用的是ID CLASSS
常用css和xpath定位
driver.find_element(By.CLASS_NAME,"channel-link").click()
# 多个classname
for ele in driver.find_elements(By.CLASS_NAME,"channel-link"):
print(ele.text)
driver.find_element(By.TAG_NAME,"input").send_keys("学习selenium")
# 最大化窗口
driver.maximize_window()
driver.get("https://www.baidu.com")
driver.find_element(By.NAME,"wd").send_keys("根据name查找")
# 点击链接
driver.find_element(By.LINK_TEXT,"新闻").click()
# 点击链接
driver.find_element(By.LINK