selenium python presence_of_element_located vs visibility_of_element_located
背景: 用WebDriverWait时,一开始用的是presence_of_element_located,我对它的想法就是他就是用来等待元素出现。结果屡屡出问题。元素默认是隐藏的,导致等待过早的就结束了。
解决:去StackOverFlow查了一下,发现我应该用visibility_of_element_located。
原文:
Well, I would guess that presenceOfElementLocated will be slighty faster because it's just check elements presence on the page while the visibilityOfElementLocated has to check the presenceand whether is element visible.
But I think it really doesn't matter from the performance perspective (what's the point if you save 0.001 second during this checking?), you better choose appropriate method depending on your use case.
- use
presenceOfElementLocatedwhen you don't care whether if element visible or not, you just need to know if it's on the page - use
visibilityOfElementLocatedwhen you need to find element which should be also visible
Look at the documentation for more info.
翻译:
我猜 presence_of_element_located 肯定会稍微快一点,因为它仅仅检查了页面是否存在该元素,而visibility_of_element_located还必须检查元素是否存在以及元素是否可见。
但是我认为从性能角度考虑,确实没啥影响。最好根据使用情况来选择正确的方法。
- presence_of_element_located: 当我们不关心元素是否可见,只关心元素是否存在在页面中。
- visibility_of_element_located: 当我们需要找到元素,并且该元素也可见。
selenium python presence_of_element_located vs visibility_of_element_located的更多相关文章
- <译>Selenium Python Bindings 5 - Waits
如今,大多数的Web应用程序使用AJAX技术.当页面加载到浏览器,页面中的元素也许在不同的时间间隔内加载.这使得元素很难定位,如果在DOM中的元素没有呈现,它将抛出ElementNotVisibleE ...
- [译]Selenium Python文档:五、Waits等待
大多数现代web应用都使用了AJAX技术.当浏览器加载一个页面的时候,该页面内的元素可能在不用的时间间隔内进行加载.这使得元素定位变得比较困难:如果一个元素还没有出现在DOM中,定位函数将会抛出一个E ...
- selenium+python : Waits---study
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.s ...
- <译>Selenium Python Bindings 6 - WebDriver API
本章涉及Selenium WebDriver的所有接口. Recommended Import Style 推荐的导入风格如下: from selenium import webdriver 然后,你 ...
- presence_of_element_located对比visibility_of_element_located
presence_of_element_located和visibility_of_element_located都是selenium里判断元素展示的方法,相信做ui自动化的小伙伴一定被这俩困扰过,本 ...
- selenium + python自动化测试环境搭建
selenium的在python平台的搭建: 搭建平台windows 准备工具如下: --------------------------------------------------------- ...
- Page Object Model (Selenium, Python)
时间 2015-06-15 00:11:56 Qxf2 blog 原文 http://qxf2.com/blog/page-object-model-selenium-python/ 主题 Sel ...
- selenium + python 多浏览器测试
selenium + python 多浏览器测试 支持库包 在学习 Python + Selenium 正篇之前,先来看下对多浏览器模拟的支持.目前selenium包中已包含webdriver,hel ...
- selenium + python 自动化测试环境搭建
selenium + python 自动化测试 —— 环境搭建 关于 selenium Selenium 是一个用于Web应用程序测试的工具.Selenium测试直接运行在浏览器中,就像真正的用户在操 ...
随机推荐
- Length 和 Width在矩形中的定义.
Length is the longer or longest dimension of a rectangle (or even an object). Ref:http://mathforum.o ...
- 层模型--固定定位(position:fixed)
fixed:表示固定定位,与absolute定位类型类似,但它的相对移动的坐标是视图(屏幕内的网页窗口)本身. 由于视图本身是固定的,它不会随浏览器窗口的滚动条滚动而变化,除非你在屏幕中移动浏览器窗口 ...
- cuda中时间用法
转载:http://blog.csdn.net/jdhanhua/article/details/4843653 在CUDA中统计运算时间,大致有三种方法: <1>使用cutil.h中的函 ...
- ajax jsonp 原理 以及对数据的处理
ajax请求 var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xml ...
- SQL Server Analysis Services 数据挖掘(1)
来源: http://technet.microsoft.com/zh-cn/library/dn633476.aspx 假如你有一个购物类的网站,那么你如何给你的客户来推荐产品呢?这个功能在很多 电 ...
- asp.net将数据导出到excel
本次应用datatable导出,若用gridview(假设gridview设为了分页显示)会出现只导出当前页的情况. protected void btnPrn_Click(object sender ...
- FileReader上传图片
实现拖拽图片,在上传至服务器前,显示图片并操控大小 利用HTML5 dragenter dragover dragleave drop 在实现图片显示方面,用了FileReader这个类 var fi ...
- python 装饰器、生成器、迭代器
# 装饰器'''由高阶函数(把一个函数名当作实参传递给另一个函数,返回值中包含函数名)和嵌套函数(函数中嵌套函数)组成功能:在不更改原函数的代码和调用方式的前提下添加新的功能装饰器本身就是一个函数.使 ...
- openerp binary filed import export
1: user xmlrpc 2: use csv file to export import but want to change the csv model field_size_limit
- EntityFramework - Migrations
EntityFramework - Migrations 對項目進行EF的數據庫升級操作.分爲開發環境與部署環境.上的操作總結. 引用: Command說明https://coding.abel.n ...