Angular 量角器-等待角度10应用程序始终失败

Angular 量角器-等待角度10应用程序始终失败,angular,typescript,selenium,automation,protractor,Angular,Typescript,Selenium,Automation,Protractor,谢谢你回答我的问题 我们已经使用量角器很多年了,取得了巨大的成功。我们所有较新的应用程序都是在angular 10中构建或升级到angular 10。我们很大程度上依赖于明确的等待。这已经很久没有给我们带来问题了。但是,由于升级是在WaitForDisplay或waitForClickable时进行的,因此当WaitForAngularEnabled=true时,它将始终超时 另一方面,如果WaitForAngularEnabled=false,并且我们使用seleniums browser.e

谢谢你回答我的问题

我们已经使用量角器很多年了,取得了巨大的成功。我们所有较新的应用程序都是在angular 10中构建或升级到angular 10。我们很大程度上依赖于明确的等待。这已经很久没有给我们带来问题了。但是,由于升级是在WaitForDisplay或waitForClickable时进行的,因此当WaitForAngularEnabled=true时,它将始终超时

另一方面,如果WaitForAngularEnabled=false,并且我们使用seleniums browser.expectedConditions,它工作正常有人看到角度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}`);
        }
    }
从“量角器”导入{browser,ElementFinder,ExpectedConditions as EC};
/**等待此组件可单击。
*@param{number}[WaitTimeOutMillimes]如果设置,则覆盖量角器默认值以获得最长等待时间。
*@返回{Promise}当元素可单击时解析的承诺。
*@memberof组件
*/
公共异步WaitForClickable(超时毫秒?:编号):承诺{
试一试{
if(browser.waitForAngularEnabled()){
wait browser.wait(EC.elementtobelickable(this.ComponentElement),timeout毫秒);
}
否则{
设bEC=browser.ExpectedConditions;
返回browser.wait(bEC.elementtobelickable(this.ComponentElement),timeoutmillizes,“名字文本字段应该可见。”);
}
}
捕获(e){
抛出新错误(`Component`+(this.DisplayName?`(${this.DisplayName})-`:'-')+`WaitForClickable:\n${e}`);
}
}
/**等待此组件的元素出现在DOM上并且可见。
*@param{number}[WaitTimeOutMillimes]如果设置,则覆盖量角器默认等待的时间。
*@返回{Promise}当元素存在且可见时解析的承诺。
*@memberof组件
*/
public async WaitForDisplayed(waittimeoutmillizes?:number):承诺{
试一试{
if(browser.waitForAngularEnabled()){
wait browser.wait(EC.and(EC.presenceOf(this.ComponentElement))、EC.visibilityOf(this.ComponentElement))、WaitTimeoutMills);
}
否则{
设bEC=browser.ExpectedConditions;
返回browser.wait(bEC.visibilityOf(this.ComponentElement),waitTimeOutMillicles,“名字文本字段应该可见”);
}
}
捕获(e){
抛出新错误(`Component`+(this.DisplayName?`(${this.DisplayName})-`:'-')+`WaitForDisplayed:\n${e});
}
}
请注意,我们必须添加if(browser.waitForAngularEnabled()),因为我们总是在等待时超时,并且我们仍然希望使用泛型方法。我认为这是因为角区永远不会稳定,但我找不到任何迹象


如果您能提供任何帮助,我们将不胜感激。

上周,这个答案被问了三次。并非所有页面都可以通过
浏览器自动显示。wairForAngularEnabled(true)
。移动甚至不是所有的角度应用程序都可以用它实现自动化。要了解如何确定您的页面是否可以使用
浏览器。wairForAngularEnabled(true)
参考请向上投票答案如果HelpedTanks@SergeyPleshakov,我尝试搜索它,但因为我太专注于angular 10,我想我找不到其他链接,但链接完全正确。hasPendingMacrotasks:true,这将导致它失败。