美文网首页我爱编程python
python+selenium常用命令集(持续收集中..)

python+selenium常用命令集(持续收集中..)

作者: 我是青菜 | 来源:发表于2017-12-01 11:27 被阅读0次

打开一个网页 get/open 

输入内容:send_keys(为空就是点击)

点击click

定位方式:

CSS样式 find_element_by_css_selector(self, css_selector)

classname: find_element_by_class_name(self, name)

tag:find_element_by_tag_name(self, name) 

name:find_element_by_name(self, name) 

部分文字:find_element_by_partial_link_text(self, link_text)

所有文字 find_element_by_link_text(self, link_text) 

xpath:find_element_by_xpath(self, xpath) 

ID:find_element_by_id(self, id_)

特殊处理:

查找frame,iframe:switch_to_frame

查找window窗口:switch_to_window(通过window_handles)

查找弹框switch_to_alert

current_window_handle # 输出当前窗口句柄

window_handles # 获取当前全部窗口句柄集合

其他操作

截图并保存 get_screenshot_as_file

执行js脚本触发一个alert弹出框  execute_script("window.alert('这是一个alert弹框。');")

添加cookies add_cookie

获取页面 Cookies get_cookie

提交 submit()

下拉选项卡Select

获取文字.text

文本清除clear

是否被选中is_selected

窗口最大化maximize_window

窗口最小化minimize_window

后退back

前进forward

关闭窗口close

退出quit




相关文章

网友评论

    本文标题:python+selenium常用命令集(持续收集中..)

    本文链接:https://www.haomeiwen.com/subject/lpiibxtx.html