赞
踩
find_element_by_id() find_element_by_name() find_element_by_class_name() find_element_by_xpath() find_element_by_css_selector() find_element_by_class_name() find_element_by_tag_name() find_element_by_link_text() find_element_by_partial_link_text
find_elements_by_id() find_elements_by_name() find_elements_by_class_name() find_elements_by_xpath() find_elements_by_css_selector() find_elements_by_class_name() find_elements_by_tag_name() find_elements_by_link_text() find_elements_by_partial_link_text
示例:找寻多个id相同的元素,并点击
elements = driver. find_elements_by_id(“id”)
for element in elements:
element.click()
以如下html代码为例:
<html>
<body>
<div id="A">
<div id="B">
<div>parent to child</div>
</div>
</div>
</body>
</html>
现根据id=A的父节点找子节点B:
Element = driver. find_element_by_id(“A”). find_element_by_tag_name(“div”)
Element = driver. find_element_by_id(“//div[@id='B']/div”)
<html>
<body>
<div id="A">
<div id="B">
<div>parent to child</div>
</div>
</div>
</body>
</html>
现根据id=B的子节点找父节点A:
element = driver.find_element_by_xpath("//div[@id='C']/...")
element = driver.find……
Select(element).select_by_index(value)
先输入、后回车
self.click_element() //先点击,触发下拉框
element = self.get_element() //获取下拉框元素
element.send_keys(__value) //输入目标值
element.send_keys(Keys.ENTER) //模拟键盘回车
直接点击:
self.click_element() //先点击,触发下拉框
driver.find_element_by……().click() //找到目标元素直接点击
input、textarea类型
富文本
单击:click()
双击:double_click()
右键点击:context_click()
悬停:move_to_element()
<input>文件上传
判断当前是否跳转至正确URL
该页面特定元素加载完成
显式等待、隐式等待
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。