Selenium 入门到精通系列:五
Selenium 入门到精通系列
PS:显式等待、隐式等待、强制等待方法
例子
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Date : 2019-04-23 16:12:33
# @Author : BenLam
# @Link : https://www.cnblogs.com/BenLam/
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep
driver=webdriver.Firefox()
driver.get("http://www.baidu.com")
wait=WebDriverWait(driver,5,0.5).until(EC.presence_of_element_located((By.ID,'kw')))
wait.send_keys("TEST")
driver.find_element_by_id("su").click()
#隐式等待
from selenium.common.exceptions import NoSuchElementException
driver.implicitly_wait(10)
driver.get("http://www.baidu.com")
try:
driver.find_element_by_id("kwsssss")
except NoSuchElementException as e:
print(e)
finally:
driver.quit()
#强制等待
driver.get("http://www.baidu.com")
sleep(5)
driver.find_element_by_id("kwsssss")
driver.quit()
Selenium 入门到精通系列:五的更多相关文章
- Selenium 入门到精通系列:六
Selenium 入门到精通系列 PS:Checkbox方法 例子 HTML: <html> <head> <title>测试页面</title> &l ...
- Selenium 入门到精通系列:四
Selenium 入门到精通系列 PS:鼠标右键.鼠标悬停.键盘操作方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019 ...
- Selenium 入门到精通系列:三
Selenium 入门到精通系列 PS:Driver_Element 常用方法 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2 ...
- Selenium 入门到精通系列:二
Selenium 入门到精通系列 PS:用户登录 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019-04-23 16:12 ...
- Selenium 入门到精通系列:一
Selenium 入门到精通系列 PS:控制浏览器窗口大小.前进.后退.刷新 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 20 ...
- GPU 编程入门到精通(五)之 GPU 程序优化进阶
博主因为工作其中的须要,開始学习 GPU 上面的编程,主要涉及到的是基于 GPU 的深度学习方面的知识.鉴于之前没有接触过 GPU 编程.因此在这里特地学习一下 GPU 上面的编程. 有志同道合的小伙 ...
- ArcGIS10从入门到精通系列实验图文教程(附配套实验数据持续更新)
@ 目录 1. 专栏简介 2. 专栏地址 3. 专栏目录 1. 专栏简介 本教程<ArcGIS从入门到精通系列实验教程>内容包括:ArcGIS平台简介.ArcGIS应用基础.空间数据的采集 ...
- redis入门到精通系列(二):redis操作的两个实践案例
在前面一篇博客中我们已经学完了redis的五种数据类型操作,回顾一下,五种操作类型分别为:字符串类型(string).列表类型(list).散列类型(hash).集合类型(set).有序集合类型(so ...
- Provisioning Services 7.6 入门到精通系列之一:PVS前期规划
1. Provisioning Services 产品概述 Provisioning Services (简称PVS)采用了一种与传统映像解决方案截然不同的方法,从根本上改变了硬件与依托硬件而运行的 ...
随机推荐
- CentOS 安装postgresql
CentOS 安装postgresql 添加postgresql官网安装源 在/etc/yum.repos.d目录下新建pgdg-10-centos.repo 文件 [pgdg10] name=P ...
- 使用@Aspect切面进行让JDBC自动关闭(Spring AOP)
原生jdbc进行测试 demo:https://github.com/weibanggang/springjdbcAspect.git
- HIDU 2094
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2094 产生冠军 Time Limit: 1000/1000 MS (Java/Others) M ...
- PCB 布线 注意哪些问题记录
1.过孔不能打在焊盘上 ,这样 焊接的时候 会有焊锡 溢出导致 短路. 2.焊盘的线引出时应该从中间引出,不应该从角落引出 3.当有较粗的电源线连接在元器件上时,最好是 有一根小线连接在元器件上,回流 ...
- 第24章 QSPI—读写串行FLASH
本章参考资料:<STM32F76xxx参考手册>.<STM32F76xxx规格书>.库帮助文档<STM32F779xx_User_Manual.chm>及<S ...
- Lua库-bit32库
Global = Global or {}; local bits = {}; function bits.bxor(num1,num2) local ret=bit32.bxor(num1,num2 ...
- NLP语言模型
语言模型: I. 基本思想 区别于其他大多数检索模型从查询到文档(即给定用户查询,如何找出相关的文档), 语言模型由文档到查询,即为每个文档建立不同的语言模型,判断由文档生成用户查 询的可能性有多大, ...
- Paths with -a does not make sense.
最近开始使用为windows的系统,进行git操作的时候出现了一个小问题. 使用命令: E:\IdeaProjects\mmall>git commit -am 'first commit in ...
- 转型大数据之学前准备,掌握linux(一)
导语:为什么要学习linux?学到什么程度? 大数据技术是运行在集群,且是linux操作系统这样的集群当中的,所以学习大数据之前,你得先掌握了linux的简单操作,没错,我们不是专门的做linux工作 ...
- centos6,python3,通过pip安装pycurl出现报错提示
Centos6.7系统,python3.6.7,通过 pip 安装pycurl出现报错: __main__.ConfigurationError: Could not run curl-config: ...