[Selenium]等待元素出现之后再消失,界面上的loading icon都属于这种类型,之前的方法总是卡死,换这种方法目前还好用的
等待元素出现之后再消失,界面上的loading icon都属于这种类型,之前的方法总是卡死,换这种方法目前还好用的
/**
* Check if the element present with customized timeout
* @param driver
* @param locator
* @param errorMessage
* @return
*/
public Boolean waitUntilElementPresent(WebDriver driver,final By locator, long timeOutInSeconds) {
Boolean isPresent = false;
for(int i=0;i<timeOutInSeconds;i++){
isPresent=SeleniumUtil.isElementPresent(driver,locator);
if(true==isPresent){
break;
}
else{
SeleniumUtil.sleep(1);
System.out.println("Wait no more than "+timeOutInSeconds+"s for loading icon display, wait "+(i+1)+"s");
}
}
return isPresent;
}
/**
* Wait until the element not present with customized timeout
* @param driver
* @param locator
* @param errorMessage
* @return
*/
public Boolean waitUntilElementNotPresent(WebDriver driver,final By locator, long timeOutInSeconds) {
Boolean isPresent = true;
for(int i=0;i<timeOutInSeconds;i++){
isPresent=SeleniumUtil.isElementPresent(driver,locator);
if(false==isPresent){
break;
}
else{
SeleniumUtil.sleep(1);
System.out.println("Wait no more than "+timeOutInSeconds+"s for loading icon disappear, wait "+(i+1)+"s");
}
}
return isPresent;
}
public void waitForLoadingDoneInNewWebPage(WebDriver driver){
By locator=By.cssSelector("div.x-mask-msg");
Boolean isPresent = this.waitUntilElementPresent(driver, locator, 10);
if(true==isPresent){
System.out.println("Loading icon display in new web page");
System.out.println("Wait for loading icon disappear in new web page");
Boolean stillPresent = this.waitUntilElementNotPresent(driver, locator, 120);
if(false==stillPresent){
System.out.println("Loading icon disappear in new web page.");
}
}
else{
System.out.println("Loading icon does'nt display in new web page.");
}
}
[Selenium]等待元素出现之后再消失,界面上的loading icon都属于这种类型,之前的方法总是卡死,换这种方法目前还好用的的更多相关文章
- [Selenium]怎样等待元素出现之后再消失,譬如Loading icon
界面上有些元素是要先等它出现,再等它消失,譬如loading icon 这个是等多个loading icon出现后消失 /** * Wait for loading icon disappear in ...
- selenium 等待元素加载
今天,尝试用代码指定自动化测试用例. 将测试record导出为C# 代码后,使用FF的drive ,发现执行一直失败,提示无法加载元素.顿时一种无力感袭来啊.还是硬着头皮找方法.尝试id name x ...
- 【亲测显式等待】Selenium:元素等待的4种方法
Selenium:元素等待的4种方法 1.使用Thread.sleep(),这是最笨的方法,但有时候也能用到而且很实用. 2.隐式等待,隐性等待是指当要查找元素,而这个元素没有马上出现时,告诉We ...
- python selenium等待特定网页元素加载完毕
selenium等待特定元素加载完毕 is_disappeared = WebDriverWait(driver, 8, 0.5, ignored_exceptions=TimeoutExceptio ...
- selenium等待机制学习笔记
转载至: https://blog.csdn.net/huilan_same/article/details/52544521 1. 强制等待 第一种也是最简单粗暴的一种办法就是强制等待sleep(x ...
- Selenium定位元素
Commands (命令) Action对当前状态进行操作失败时,停止测试 Assertion校验是否有产生正确的值 Element Locators指定HTML中的某元素 Patterns用于模式匹 ...
- selenium界面元素定位
一. Selenium界面元素定位 本文元素定位以das2为例 #导入包 from selenium import webdriver #打开火狐驱动 driver=webdriver ...
- 强制等待&隐士等待&显示等待&元素定位方法封装
前言 问题 学习selenium的同学估计大多数都遇见过一个问题 明明页面已经精准的定位到了元素,但是执行脚本的时候却经常报错没找到元素.其实原因很简单,就是脚本执行的速度很快,而浏览器加载页面的时候 ...
- python+selenium遇到元素定位不到的问题,顺便记录一下自己这次的错误(报错selenium.common.exceptions.NoSuchElementException)
今天在写selenium一个发送邮件脚本时,遇到一些没有找到页面元素的错误.经过自己反复调试,找原因百度,终于解决了.简单总结一下吧,原因有以下几点: 一:Frame控件嵌套,.Frame/Ifram ...
随机推荐
- 捕捉过滤器(CaptureFilters)和显示过滤器(DisplayFilters)--Wireshark
Wireshark的基本使用——过滤器 前言 网络上关于Wireshark的教程已有不少,博主就简单介绍一下Wireshark分析数据包时最重要的技巧之一的过滤器..一次性嗅探到的数据包有很多,想要高 ...
- [BZOJ3470]Freda’s Walk
bzoj description 雨后的Poetic Island空气格外清新,于是Freda和Rainbow出来散步. Poetic Island的交通可以看作一张\(n\)个点.\(m\)边的有向 ...
- .NET4.0中使用4.5中的 async/await 功能实现异步
在.NET Framework 4.5中添加了新的异步操作库,但是在.NET Framework 4.0中却无法使用.这时不免面临着抉择,到底是升级整个解决方案还是不使用呢? 如果你的软件还没发布出去 ...
- 监控操作系统的CPU、内存、磁盘
Linux 四大件:CPU.内存.磁盘.网络 CPU 就像人的大脑,主要负责相关事情的判断以及实际处理的机制. CPU的性能主要体现在其运行程序的速度上.影响运行速度的性能指标包括CPU的工作频率.C ...
- mysql 源代码目录及安装目录介绍
1.源代码目录介绍: 1.BUILD BUILD目录是编译.安装脚本目录,绝大部分以compile-开头,其中的SETUP.sh脚本为C和C++编译器设置了优化选项.2.client cl ...
- (原创)AP6212移植到AM335X自主开发板上
转载请指明出处. 参考<关于AM335X移植SDIO WIFI的简易教程> http://www.deyisupport.com/question_answer/dsp_arm/sitar ...
- 1.Appium环境搭建
1.安装node.js (1)去node官网下载,根据操作系统的不同选择不同对应的版本(https://nodejs.org/en/download/) (2)下载对应的版本后进行安装,一直下一步直至 ...
- opensuse下配置IP、DNS、GATEWAY
本人物理主机IP描述 IPv4 地址 . . . . . . . . . . . . : 192.168.1.101(首选)子网掩码 . . . . . . . . . . . . : 255.25 ...
- Appcan、apicloud、HBuilder 不同之处解析
来源:http://www.mamicode.com/info-detail-1129829.html 现在Hybrid app是一中非常火热的开发模式,在国内对应的开发工具也乱象丛生,有WeX5.c ...
- Bootstrap-Other:UI 编辑器
ylbtech-Bootstrap-Other:UI 编辑器 1.返回顶部 1. Bootstrap UI 编辑器 以下是 15 款最好的 Bootstrap 编辑器或者是在线编辑工具. 1. Boo ...