javascript - 等待动画直到在 Selenium 中完成
问题描述
我面临等待动画直到完成的问题。到目前为止,使用 selenium 函数就足够了
等待.直到(预期条件....
但现在不可能了。我有 HTML 中的元素
<div content-c2="" class="nav-loader"></div>
该元素具有以下 CSS 样式:
.nav-header[content-c2] .nav-loader[content-c2] {
width: 100%;
height: 2px;
background: #EE3D42;
float: left;
clear: both;
animation: 1.5s ease-out 0.5s 1 slideInFromLeft;
我需要等到加载程序完成,然后我才能继续执行进一步的硒操作,例如单击,....我想避免使用静态延迟等。有人可以帮我定制动画完成后检查的特定功能? 谢谢提示...
解决方案
您可以查看位置
waitAnimationComplete = async(selector, newDriver = driver) => {
const elem = await newDriver.wait(until.elementLocated(By.css(selector)))
const loc1 = await elem.getRect()
await newDriver.wait(new Condition('wait animation complete', () => {
return new Promise((resolve, reject) => {
elem.getRect()
.then(loc2 => resolve(loc1.x === loc2.x && loc1.y === loc2.y))
})
}))
};
称呼
await waitAnimationComplete('your css selector of button ...')
推荐阅读
- python - 从阈值蒙版生成圆形粒子的分割蒙版?
- c++ - 如何将字符串映射到对象成员?
- haskell - 评估部分应用的功能
- append - 如何使用通用模式在 Nuxt 中附加 html
- json - Pandas read_json - 停止将索引转换为日期时间
- facebook - 如何将 Messenger 数据提取到我自己的数据库中?
- python - 更改函数的返回值会影响不应受到影响的元素
- firebase - 如何向 Firestore 验证 Firebase 功能/管理员请求
- laravel - 如何提高电子邮件的健壮性?[邮筒,laravel]
- angular - Angular 9 PrimeNg 如何设置 p-table 边框颜色的样式?