Selenium
DOM 元素
选择元素
使用driver.find_element
方法选择元素。
python
element = driver.find_element(By.ID, 'element_id')
一共支持以下几种传统选择器:
By.CLASS_NAME
通过类名选择By.CSS_SELECTOR
通过 CSS 选择器选择By.ID
通过元素 ID 选择By.NAME
通过元素名称选择By.LINK_TEXT
通过链接文本选择By.PARTIAL_LINK_TEXT
通过部分链接文本选择By.TAG_NAME
通过标签名选择By.XPATH
通过 XPath 选择(这是一种强大的选择器,有点类似于正则表达式)