[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 ...
随机推荐
- python3 tkinter 桌面软件教程
效果图 """"brid布局""" from tkinter import * import tkinter.filedialog ...
- strapi 开源api && 内容管理平台试用
strapi 是一个开源的api && 内容管理平台,功能操作起来还是比较方便简单的. 安装 使用docker && docker-compose 代码clone gi ...
- CCFLOW5 SDK 模式 开发环境配置
在群里和论坛里问了N次都没有人回答,最终在QQ好友[冥(276669806) ]的帮助下成功配置了SDK开发环境.现将具体配置步骤分享给大家.1.打开VS2010 新建一个网站项目2.将CCFlow\ ...
- 【开源推荐】PredictionIO:构建预测功能的机器学习服务器
PredictionIO是一款开源的机器学习服务器,开发工程师和数据分析师可以使用它构建智能应用程序,并且还可以做一些预测功能,比如个性化推荐.发现内容等.好比开发者可以使用数据库服务器过滤信息. P ...
- Python VIL Realse
#!/usr/bin/python #-*- coding:utf-8 –*- import os import sys import re import shutil import xlrd imp ...
- emacs之配置4,颜色插件
来自https://github.com/oneKelvinSmith/monokai-emacs/blob/master/monokai-theme.el monokai-theme.el ;;; ...
- Jenkins集成selenium
目的:将selenium用例集成到Jenkins,需要执行时,只需要执行curl命令即可. 1.准备selenium测试脚本 from selenium import webdriver import ...
- IPv6 Tunnel Broker+ROS搭建6TO4(IPV6)网络
准备条件:1.公网IPV4的IP2.ROS+IPV6的DHCP,本测试在ROS6.24版本下测试通过3. IPv6 Tunnel Broker:https://www.tunnelbroker.net ...
- MOBA游戏的网络同步技术
转自:http://www.gameres.com/750888.html 在5月13日Unite 2017 案例分享专场上,蓝港互动<闹闹天宫>项目组的主程序陈实分享了MOBA游戏的网络 ...
- 无法定位程序输入点 Can't load package
---------------------------Toggle Form/Unit (F12): bcb.exe - 无法找到入口--------------------------- 无法定位程 ...