显示等待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 ...
随机推荐
- tensorflow 之Dataset数据集之批量数据
###生成批次数据 import tensorflow as tf '''reapt()生成重复数据集 batch()将数据集按批次组合''' file_name = ['img1','img2',' ...
- Node.js实战6:定时器,使用timer延迟执行。
setTimeout 在nodejs中,通过setTimeout函数可以达到延迟执行的效果,这个函数也常被称为定时器. 一个简单的例子: console.log( (new Date()).getSe ...
- HashSet -无序,不重复集合
package cn.learn.collection.Set; import java.util.Objects; public class IsPerson { private int age; ...
- Java笔记——Map集合
Map集合接口 Map集合与Collection不是从属关系,是平级的 Map集合的映射特点 一个映射不能包含重复的键,由此键只能允许有一个空null 每个键最多只能和一个值对应 值可以重复,由此值允 ...
- mysql 主从复制(mysql双机热备的实现)
转:http://blog.csdn.net/qq394829044/article/details/53203645 Mysql数据库没有增量备份的机制,当数据量太大的时候备份是一个很大的问题.还好 ...
- LOJ 2183 / SDOI2015 序列统计 (DP+矩阵快速幂)
题面 传送门 分析 考虑容斥原理,用总的方案数-不含质数的方案数 设\(dp1[i][j]\)表示前i个数,和取模p为j的方案数, \(dp2[i][j]\)表示前i个数,和取模p为j的方案数,且所有 ...
- spark连接hive找不到table
Caused by: org.apache.spark.sql.catalyst.analysis.NoSuchTableException: Table or view 'xxxx' not fou ...
- Redis设计与实现 -- 动态字符串对象(SDS)
1. 动态字符串( simple dynamic string, SDS) 在 Redis 中,当需要可以被重复修改的字符串时,会使用 SDS 类型 ,而不是 C 语言中默认的 C 字符串类型 .举个 ...
- 图解git中的最常用命令
图解git中的最常用命令 Git命令参考手册(文本版) git init # 初始化本地git仓库(创 ...
- Pull Request的正确打开方式(如何在GitHub上贡献开源项目)
Pull Request的正确打开方式(如何在GitHub上贡献开源项目) GitHub的官方帮助如下: Fork A Repo: https://help.github.com/articles/f ...