angular - 量角器 - 等待 Angular 10 应用程序总是失败
问题描述
感谢您提出我的问题。
多年来,我们一直在使用量角器并取得了巨大的成功。我们所有较新的应用程序都在 Angular 10 中构建或升级到 Angular 10。我们非常依赖我们的显式等待。这已经很长时间没有给我们带来问题了。但是,由于我们在 waitForDisplayed 或 waitForClickable 时升级,当 WaitForAngularEnabled = true 时它总是会超时。
另一方面,如果 WaitForAngularEnabled = false 并且我们使用 seleniums browser.expectedConditions 它可以正常工作。有人看到 Angular 10 和量角器有什么问题吗?
- 节点版本:8.17.0
- 打字稿版本:“^3.9.5”
- 量角器版本:7.0.0
- 角度版本:10.0.0
这是我们的通用等待方法
import { browser, ElementFinder, ExpectedConditions as EC } from 'protractor';
/** Wait for this Component to be clickable.
* @param {number} [waitTimeoutMilliseconds] If set, override protractor defaults for maximum time to wait.
* @returns {Promise<void>} A promise that resolves when the element is clickable.
* @memberof Component
*/
public async WaitForClickable(timeoutMilliseconds?: number): Promise<void> {
try {
if(browser.waitForAngularEnabled()){
await browser.wait(EC.elementToBeClickable(this.ComponentElement), timeoutMilliseconds);
}
else{
let bEC = browser.ExpectedConditions;
return browser.wait(bEC.elementToBeClickable(this.ComponentElement), timeoutMilliseconds, "First Name text field should be visible.");
}
}
catch (e) {
throw new Error(`Component` + (this.DisplayName ? ` (${this.DisplayName}) - ` : ' - ') + `WaitForClickable:\n${e}`);
}
}
/** Waits for this Component's element to be both present on the DOM and visible.
* @param {number} [waitTimeoutMilliseconds] If set, override protractor defaults for how long to wait.
* @returns {Promise<void>} A promise that resolves when the element is present and visible.
* @memberof Component
*/
public async WaitForDisplayed(waitTimeoutMilliseconds?: number): Promise<void> {
try {
if(browser.waitForAngularEnabled()){
await browser.wait(EC.and(EC.presenceOf(this.ComponentElement), EC.visibilityOf(this.ComponentElement)), waitTimeoutMilliseconds);
}
else{
let bEC = browser.ExpectedConditions;
return browser.wait(bEC.visibilityOf(this.ComponentElement), waitTimeoutMilliseconds, "First Name text field should be visible.");
}
}
catch (e) {
throw new Error(`Component` + (this.DisplayName ? ` (${this.DisplayName}) - ` : ' - ') + `WaitForDisplayed:\n${e}`);
}
}
请注意,我们必须添加 if(browser.waitForAngularEnabled()) 因为我们总是在等待时超时,我们仍然想使用通用方法。我认为这是因为角度区域永远不会稳定,但我找不到任何迹象。
任何帮助,将不胜感激
解决方案
推荐阅读
- python - 如何在 Django App 中使用 Celery 异步运行任务?
- python - Python 'texttract' 库安装失败
- javascript - Firestore - 通过时间戳查询不返回结果
- python - 熊猫如何将父数据框与 2 个子数据框合并
- spring-boot - 了解 Spring Boot 执行器`http.server.requests` 指标 MAX 属性
- mongodb - 数数。结果文档中的匹配值
- reactjs - TypeError:无法读取未定义的属性“then” - 尝试在纯 javascript 中获取数据
- swift - 关于函数@IBAction的参数是什么。为什么我可以通过这种方式添加图层动画
- java - 如何在不调用规则的情况下测试 drool 文件中存在的函数?
- firebase - 是否可以重命名 Firestore 集合中的字段?