selenium定位----By方法
from selenium.webdriver.common.by import By ### By关键字的使用 b = webdriver.Chrome() b.implicitly_wait(30) b.get('file:///E:/ZM20190316/2.Selenium/TestDemo/checkBoxDemo.html') b.maximize_window() ## 实现元素定位与操作相分离 ele_loc = (By.ID,'id1') b.find_element(*ele_loc).click() ele_p = b.find_element_by_class_name("form-horizontal") eles = b.find_elements(By.TAG_NAME,'input') print(len(eles)) sleep(3) b.quit()