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测试直接运行在浏览器中,就像真正的用户在操 ...
随机推荐
- tomcat的webapp下的root文件夹的作用是什么
1.基本一样..只是表示不同的tomcat的http路径而已. root目录默认放的是tomcat自己的一个项目,如:http://localhost:8080/默认访问root项目 对于webapp ...
- Express难点解析
app.js 应用程序入口文件1.// view engine setup 设置视图引擎app.set('views', path.join(__dirname, 'views'));//告诉expr ...
- 第一次用Github desktop(mac)提交代码遇到的问题
1.新建代码仓库 2.生成密钥 ssh-keygen -C 'your@email.address' -t rsa 3.到根目录下的.ssh文件夹下找到id_rsa.pub文件,将里面的内容复制到下图 ...
- php 备份数据库脚本
<?php// 备份数据库$host = "localhost";$user = "root"; //数据库账号$password = "123 ...
- Canvas中点到点的路径运动
/*随机生成两个点,然后以两点为端点,进行运动,主要使用了SetInterval,对画布进行不断的擦除描绘的操作*/1 <!DOCTYPE html> <html xmlns=&qu ...
- 解决xp共享的批处理文件
在空白地方点右键选择新建一个文本文档,将默认的“新建 文本文档.txt”文件名改名为以下红色加粗字体内容,再复制红色内容以下的黑字部分到改名后的文档.其他文件生成的方法相同.完成后根据需要双击CMD扩 ...
- SignalR实现B/S系统对windows服务运行状态的监测
基于SignalR实现B/S系统对windows服务运行状态的监测 通常来讲一个BS项目肯定不止单独的一个BS应用,可能涉及到很多后台服务来支持BS的运行,特别是针对耗时较长的某些任务来说,Windo ...
- AdminLTE
AdminLTE搭建前端 0 Asp.Net Core 项目实战之权限管理系统(0) 无中生有 1 Asp.Net Core 项目实战之权限管理系统(1) 使用AdminLTE搭建前端 2 Asp ...
- 【转】分享II→IV FPGA本人的几个版本电源模块设计的方案
很多人问我FPGA的电源怎么怎么着,当然也有人瞎忽悠乱设计,当然我的设计也不是很完美...这里把我当年第一次设计FPGA,到现在的电源方案,几个演变.分析的过程,给大家讲讲... (1)FPGA电源方 ...
- go程序性能优化
性能优化总结: 1 尽量避免频繁创建对象,即减少&{},new,make的使用2 数组可当切片用,当需要使用切片时,可考虑能使用数组来减少切片的创建3 当某类临时对象被多个协频繁程使用时,可用 ...