显示等待WebDriverWait+lambda
代码,关键代码标红
参考文章:https://www.cnblogs.com/yoyoketang/p/6517477.html
#coding:utf-8
'''
这里写了一个百度搜索页的pageobject
'''
from PageElement.readYaml import parseyaml
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC class Baidu_page():
'''
百度搜索page类
''' getElement = parseyaml() search_box = getElement["baiduPage"]["search_box"]["value"]
baidu_button = getElement["baiduPage"]["baidu_button"]["value"]
search_result = getElement["baiduPage"]["search_result"]["value"] def __init__(self,driver):
self.driver = driver def input_search(self,keyword,type_a="css"):
'''输入搜索关键词'''
self.driver.find_element(type_a,self.search_box).send_keys(keyword) def click_baidubutton(self,type_a="css"):
'''点击百度一下按钮'''
self.driver.find_element(type_a, self.baidu_button).click() def verification_result(self,type_a="css"):
'''用例结果验证'''
WebDriverWait(self.driver,10).until(lambda x: x.find_element("css selector",self.search_result)) results = self.driver.find_elements("css selector",self.search_result)
nanjing_baike = results[0].text
return nanjing_baike
显示等待WebDriverWait+lambda的更多相关文章
- selenium中的三种等待方式(显示等待WebDriverWait()、隐式等待implicitly()、强制等待sleep())---基于python
我们在实际使用selenium或者appium时,等待下个等待定位的元素出现,特别是web端加载的过程,都需要用到等待,而等待方式的设置是保证脚本稳定有效运行的一个非常重要的手段,在selenium中 ...
- 显示等待WebDriverWait
显示等待:WebDriverWait 等待页面加载完成,找到某个条件发生后再继续执行后续代码,如果超过设置时间检测不到则抛出异常 WebDriverWait(driver, timeout, poll ...
- python selenium2 中的显示等待WebDriverWait与条件判断expected_conditions举例
#coding=utf-8from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium. ...
- 【转】python selenium2 中的显示等待WebDriverWait与条件判断expected_conditions举例
#coding=utf-8 from selenium import webdriver from selenium.webdriver.common.by import By from seleni ...
- 显示等待WebDriverWait+EC
参考:https://www.cnblogs.com/yoyoketang/p/6538505.html 百度搜索关键字,等待搜索结果页面显示完成后,验证搜索结果的第一条记录 通过WebDriverW ...
- Selenium 定位元素原理,基本API,显示等待,隐式等待,重试机制等等
Selenium 如何定位动态元素: 测试的时候会遇到元素每次变动的情况,例如: <div id="btn-attention_2030295">...</di ...
- selenium等待方式之显示等待
有时候,页面元素并未及时加载出来导致后面的步骤无法执行 这里就需要在加载前添加等待时间,让目标元素有足够的时间加载出来 第一种方法:使用time.sleep() 这种方法过于强制,无论元素是否加载出来 ...
- python+selenium显示等待、隐式等待和强制等待的区别
在实际使用selenium或者appium时,等待下个等待定位的元素出现,特别是web端加载的过程,都需要用到等待,而等待方式的设置是保证脚本稳定有效运行的一个非常重要的手段,在selenium中(a ...
- 9.0 toast定位+WebDriverWait显示等待
Toast 判断-----基本操作问题 首先基本操作,进入安卓市场的账号密码页面--- from appium import webdriver from selenium.webdriver.su ...
随机推荐
- Linux libOpenThreads库链接冲突错误
最近在linux 上安装了3.7.0版本的OpenSceneGraph,而在安装之前没有完全卸载之前安装的3.6.3版本,导致在编译程序链接时出现库引用冲突,在便以后出现以下警告信息: /usr/bi ...
- U盘修复教程--使用量产工具和芯片检测工具
U盘修复教程(金士顿DT101) 本教程使用量产工具(量产可理解为强制恢复出厂设置),量产有风险(U盘彻底报废),根据教程所造成所有损失均与本文作者无关. ·第一步:下载ChipGenius_v4_0 ...
- Self-Attention 和 Transformer
1.Self-Attention 之前的RNN输入是难以并行化的,我们下一个输入可能依赖前一个输出,只有知道了前面的输出才能计算后面的输出. 于是提出了 self-attention ,但是这时候 $ ...
- Map遍历方式
entrySet 推荐 最常用,性能很好 示例: for (Map.Entry<Integer, Integer> entry : map.entrySet()) { System.out ...
- 5.1properties属性
需求: 将数据库连接参数单独配置在db.properties文件中,只需在SqlMapconfig.xml中加载db.properties的属性值. 在SqlMapconfig.xml中就不需要对数据 ...
- CentOS7没有ifconfig/route/arp/netstat等命令的解决方案
查看提供 ifconfig 命令的包 [root@bogon ~]# yum search ifconfig 这里选择安装net-tools包即可 [root@bogon ~]# yum instal ...
- ExcelVBA 操作putty
Private Sub login(ip As String, userName As String, password As String) Dim TaskID As Long '设置进程id p ...
- web开发jsp页面遇到的一系列问题
一:web总结 1.jsp页面知识点巩固 1.1字符串数字格式化转换 <%@ taglib prefix="fmt" uri="http://java.sun.co ...
- java.net.ProtocolException: Exceeded stated content-length of: '13824' bytes
转自:https://blog.csdn.net/z69183787/article/details/18967927 1. 原因: 因为weblogic会向response中写东西造成的,解决方式是 ...
- 安卓构架组件——概述 Android Architecture Components
谷歌官文文档地址:https://developer.android.google.cn/topic/libraries/architecture 安卓构架组建是库的集合:帮助你设计健壮的.易测试的. ...