#!/usr/bin/env python
# -*- coding:utf-8 -*-
# 通过选项的顺序,第一个为0
select_by_index(index)
# 通过value属性
select_by_value(value)
# 通过选项可见文本
select_by_visible_text(text)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
deselect_by_index(index)
deselect_by_value(value)
deselect_by_visible_text(text)
deselect_all()
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# 确认
driver.switch_to.alert.accept()
# 取消
driver.switch_to.alert.dismiss()
# 在弹出框输入内容
driver.switch_to.alert.send_keys("输入数据")
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from selenium.common.exceptions import NoSuchElementException
# 判断元素是否存在
def isElementPresent(self, by, value):
try:
element =self.driver.find_element(by=by, value=value)
except NoSuchElementException as e:
# 发生了NoSuchElementException异常,说明页面中未找到该元素,返回False
return False
else:
# 没有发生异常,表示在页面中找到了该元素,返回True
return True
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |