标签:let 循环 页面 for循环 sele partial max utf-8 _id
#-*-coding:utf-8-*- from selenium import webdriver f = webdriver.Chrome("D:\\Documents\\Downloads\\chromedriver.exe") f.get("http://www.baidu.com") f.find_element_by_id(‘kw‘).send_keys(‘selenium‘) f.find_element_by_id(‘su‘).click()
<input type="text" class="s_ipt" name="wd" id="kw" maxlength="100" autocomplete="off"> #-*-coding:utf-8-*- from selenium import webdriver f = webdriver.Chrome("D:\\Documents\\Downloads\\chromedriver.exe") f.get("http://www.baidu.com") f.find_element_by_name(‘wd‘).send_keys(‘selenium‘) f.find_element_by_id(‘su‘).click() f.quit()
#-*-coding:utf-8-*- from selenium import webdriver f = webdriver.Chrome("D:\\Documents\\Downloads\\chromedriver.exe") f.get("http://www.baidu.com") f.find_element_by_class_name(‘s_ipt‘).send_keys(‘selenium‘) f.find_element_by_id(‘su‘).click() f.quit() 要查找的都是要唯一的
标签名 input标签 一般不唯一 #-*-coding:utf-8-*- from selenium import webdriver f = webdriver.Chrome("D:\\Documents\\Downloads\\chromedriver.exe") f.get("http://www.baidu.com") inputs = f.find_elements_by_tag_name(‘input‘) for i in inputs: if i.get_attribute(‘autocomplete‘) == ‘off‘: i.send_keys(‘selium‘) f.find_element_by_id(‘su‘).click() f.quit() for循环勾选所有复选框
#-*-coding:utf-8-*- from selenium import webdriver f = webdriver.Chrome("D:\\Documents\\Downloads\\chromedriver.exe") f.get("http://www.baidu.com") f.find_element_by_link_text("新闻").click() f.quit()
#-*-coding:utf-8-*- from selenium import webdriver f = webdriver.Chrome("D:\\Documents\\Downloads\\chromedriver.exe") f.get("http://www.baidu.com") f.find_element_by_partial_link_text("123").click() f.quit()
标签:let 循环 页面 for循环 sele partial max utf-8 _id
原文地址:https://www.cnblogs.com/sunnybowen/p/10486892.html