Python3+Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )
!/usr/bin/env python
-*- coding:utf-8 -*-
'''
Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )
'''
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.ui import WebDriverWait
import time,os # about:addons 火狐浏览器安装组件,访问的地址 # <input id="kw" name="wd" class="s_ipt" value="" maxlength="255" autocomplete="off">
#id
keys="设置"
delay=5
url="https://www.baidu.com/"
driver=webdriver.Firefox() driver.get(url) #让弹窗页面不显示
# js='document.getElementById("id名字").style.display="none";' #通过脚本方式操作 id name tagname classname css
# document.getElementById("")
# document.getElementsByName("")
# document.getElementsByTagName("")
# document.getElementsByClassName("")
# document.querySelectorAll("") #文件下载-待调试
# fp = webdriver.FirefoxProfile()
# fp.set_preference("browser.download.folderList",2)
# fp.set_preference("browser.download.manager.showWhenStarting",False)
# fp.set_preference("browser.download.dir", os.getcwd())
# fp.set_preference("browser.helperApps.neverAsk.saveToDisk",
# "application/octet-stream")
#
# driver = webdriver.Firefox(firefox_profile=fp)
# driver.get("https://pypi.org/project/selenium/#files")
# driver.find_element_by_partial_link_text("selenium-3.141.0.tar.gz").click()
# #确定下载
# t=driver.switch_to.alert
# t.accept() #等待使用
# 强制等待
time.sleep(delay) #隐形等待
driver.implicitly_wait(delay) #显示等待
input_str=WebDriverWait(driver,10).until(lambda driver:driver.find_element(By.ID,"kw"),message="error!")
input_str.send_keys(keys) kk = WebDriverWait(driver,10).until(lambda driver:driver.find_element_by_id("kw"),message="worry!")
kk.send_keys("测试") """参考https://www.cnblogs.com/lvzb86/p/9321929.html
click(on_element=None) ——单击鼠标左键 click_and_hold(on_element=None) ——点击鼠标左键,不松开 context_click(on_element=None) ——点击鼠标右键 double_click(on_element=None) ——双击鼠标左键 drag_and_drop(source, target) ——拖拽到某个元素然后松开 drag_and_drop_by_offset(source, xoffset, yoffset) ——拖拽到某个坐标然后松开 key_down(value, element=None) ——按下某个键盘上的键 key_up(value, element=None) ——松开某个键 move_by_offset(xoffset, yoffset) ——鼠标从当前位置移动到某个坐标 move_to_element(to_element) ——鼠标移动到某个元素 move_to_element_with_offset(to_element, xoffset, yoffset) ——移动到距某个元素(左上角坐标)多少距离的位置 perform() ——执行链中的所有动作 release(on_element=None) ——在某个元素位置松开鼠标左键 send_keys(*keys_to_send) ——发送某个键到当前焦点的元素 send_keys_to_element(element, *keys_to_send) ——发送某个键到指定元素
""" """参考https://www.cnblogs.com/lvzb86/p/9492097.html
title_is:判断当前页面的title是否等于预期
title_contains:判断当前页面的title是否包含预期字符串
presence_of_element_located:判断某个元素是否被加到了dom树里,并不代表该元素一定可见
visibility_of_element_located:判断某个元素是否可见. 可见代表元素非隐藏,并且元素的宽和高都不等于0
visibility_of:跟上面的方法做一样的事情,只是上面的方法要传入locator,这个方法直接传定位到的element就好了
presence_of_all_elements_located:判断是否至少有1个元素存在于dom树中。举个例子,如果页面上有n个元素的class都是'column-md-3',那么只要有1个元素存在,这个方法就返回True
text_to_be_present_in_element:判断某个元素中的text是否 包含 了预期的字符串
text_to_be_present_in_element_value:判断某个元素中的value属性是否包含了预期的字符串
frame_to_be_available_and_switch_to_it:判断该frame是否可以switch进去,如果可以的话,返回True并且switch进去,否则返回False
invisibility_of_element_located:判断某个元素中是否不存在于dom树或不可见
element_to_be_clickable - it is Displayed and Enabled:判断某个元素中是否可见并且是enable的,这样的话才叫clickable
staleness_of:等某个元素从dom树中移除,注意,这个方法也是返回True或False
element_to_be_selected:判断某个元素是否被选中了,一般用在下拉列表
element_located_to_be_selected
element_selection_state_to_be:判断某个元素的选中状态是否符合预期
element_located_selection_state_to_be:跟上面的方法作用一样,只是上面的方法传入定位到的element,而这个方法传入locator
alert_is_present:判断页面上是否存在alert
""" driver.quit()
Python3+Selenium3+webdriver学习笔记14(等待判断 鼠标事件 )的更多相关文章
- Python3+Selenium3+webdriver学习笔记8(单选、复选框、弹窗处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记8(单选.复选框.弹窗处理)''' from selenium ...
- Python3+Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记13(js操作应用:弹出框无效如何处理)'''from sel ...
- Python3+Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记12(js操作应用:滚动条 日历 内嵌div)'''from ...
- Python3+Selenium3+webdriver学习笔记11(cookie处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记11(cookie处理)'''from selenium im ...
- Python3+Selenium3+webdriver学习笔记10(元素属性、页面源码)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记10(元素属性.页面源码)'''from selenium i ...
- Python3+Selenium3+webdriver学习笔记9(发送富文本信息及上传文件处理)
#!/usr/bin/env python# -*- coding:utf-8 -*-'''Selenium3+webdriver学习笔记9(发送富文本信息及上传文件处理)'''from seleni ...
- Python3+Selenium3+webdriver学习笔记6(多窗口切换处理)
#!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...
- Python3+Selenium3+webdriver学习笔记5(模拟常用键盘和鼠标事件)
#!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...
- Python3+Selenium3+webdriver学习笔记7(选择多链接的结果、iframe、下拉框)
#!/usr/bin/env python# -*- coding:utf-8 -*- from selenium import webdriverfrom selenium.webdriver.co ...
随机推荐
- openstack 虚拟机添加网卡
Openstack dashborad是没有给虚拟机添加网卡这个功能的,但是后台是有这行的接口的. 首先我们创建一个虚拟机,这个虚拟机制11.11.11网段的如图:
- thinkpad取消fn键功能
转自:https://bbs.thinkpad.com/thread-1834235-1-1.html 1就是一直觉得fn建自动开启很烦人,于是百度后得到 我们可以 控制面板 -- 键盘--think ...
- 一步步实现 Prism + MEF(一)--- 搭建框架
第一步:构建一个名为Bootstrapper的类作为引导程序. class Bootstrapper : MefBootstrapper { } 第二步:在MainWindow窗体中添加一个Coont ...
- 使用BIND安装智能DNS服务器(三)---添加view和acl配置
智能DNS的配置主要修改named.conf文件,利用view和acl来实现. acl文件内容,这里只列出一部分,具体详细的可以参考这个网址 纯真IP库,给出了十分详细的IP地址,下载安装后,打开软件 ...
- SQL 分割字符串
USE [AppCloud] GO /****** Object: UserDefinedFunction [dbo].[splitstr] Script Date: 12/19/2013 09:33 ...
- std::function"函数"对象包装器
语义: 类模板std::function是可调用对象的包装器,可以包装除了类成员之外的所有可调用对象.包括,普通函数,函数指针,lambda,仿函数.通过指定的模板参数,它可以用统一的方式保存,并延迟 ...
- 数据库路由中间件MyCat - 源代码篇(8)
此文已由作者张镐薪授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 3. 连接模块 3.5 后端连接 对于后端连接,我们只关心MySQL的. 从后端连接工厂开始MySQLCon ...
- (转)深度学习(Deep Learning, DL)的相关资料总结
from:http://blog.sciencenet.cn/blog-830496-679604.html 深度学习(Deep Learning,DL)的相关资料总结 有人认为DL是人工智能的一场革 ...
- uva11400 Lighting System Design
题目大意: 有一个照明系统需要用到n种灯,每种灯的电压为V,电源费用K,每个灯泡费用为C,需要该灯的数量为L.注意到,电压相同的灯泡只需要共享一个对应的电源即可,还有电压低的灯泡可以被电压高的灯泡替代 ...
- MySQL 5.7 INFORMATION_SCHEMA 详解
refman mysql 5.7 INFORMATION_SCHEMA提供了对数据库元数据的访问,MySQL服务器信息,如数据库或表的名称,列的数据类型,访问权限等. 有时也把这些信息叫做数据字典或系 ...