代码之家  ›  专栏  ›  技术社区  ›  nhrcpt

量角器-添加计数函数返回“AngularJS可测试性和角度可测试性都未定义…”错误

  •  0
  • nhrcpt  · 技术社区  · 6 年前

    我正在尝试为应用程序上的按钮单击创建循环。为此,我需要计算表中按钮所在的行数。所以我创建了这个脚本:

    require('..\\waitAbsent.js');
    require("../node_modules/jasmine-expect/index.js");
    var EC = protractor.ExpectedConditions;
    
    describe('Demo_Test For count', function() {
    
    
    beforeAll(function () {
        browser.driver.manage().window().maximize();
        browser.get(globalVariables.loginMain);
        globalVariables.Email_Input_box.sendKeys(globalVariables.Demo_User);
        globalVariables.Password_Input_Box.sendKeys(globalVariables.Demo_PWD);
        globalVariables.Submit_Button.click();
        browser.wait(EC.invisibilityOf(globalVariables.Submit_Button), 25000, 'submit button is not disappearing yet');
    });
    
    
    it('Dashboard Title Validation', function () {
    
        expect(globalVariables.ESY_DB_Label.isDisplayed());
        expect(globalVariables.ESY_DB_Label.getText()).toEqual('HomePage')
    
    });
    
    //count block
    
    
     globalVariables.tableData_Dashboard.all(by.tagName("tr")).count().then(function (Count) {
    
        console.log('\n the count of the rows are ' + Count + '\n');
    
    });
    //count block end
    
    
    it("1+1", function () {
    
        let i = 1;
        let j = i + i;
        expect(j).toBe(2);
    
    })
    
    });
    

    当我运行这个脚本时,所有的测试都失败了,甚至是我刚添加1+1的第二个测试!日志如下:

    学生注册页内容验证1+1 信息: 错误:等待量角器与页面同步时出错:“AngularJS可测试性和角度可测试性都未定义。这可能是因为这是一个无角度的页面,也可能是因为您的测试涉及客户端。 导航,可以干扰量角器的引导。见 http://git.io/v4gXM 详情 堆栈: 错误:等待量角器与页面同步时出错:“AngularJS可测试性和角度可测试性都未定义。这可能是因为这是一个无角度的页面,也可能是因为您的测试涉及客户端。 导航,可以干扰量角器的引导。见 http://git.io/v4gxm 详情 在runwaitforangularscript.then(c:\esy_desktop_v_2\node_modules\protractor\build\browser.js:463:23) 在managedPromise.invokeCallback(c:\esy_desktop_v_2\node_modules\selenium webdriver\lib\promise.js:1376:14) 在taskqueue.execute(c:\esy_desktop_v_2\node_modules\selenium webdriver\lib\promise.js:3084:14) 在taskqueue.executenext(c:\esy_desktop_v_2\node_modules\selenium webdriver\lib\promise.js:3067:27) 异步运行时(c:\esy_desktop_v_2\node_modules\selenium webdriver\lib\promise.js:2927:27) 在c:\esy_desktop_v_2\node_modules\selenium webdriver\lib\promise.js:668:7 at process._tickcallback(内部/process/next_tick.js:68:7)

    但是,如果我对这个块进行注释以进行计数,那么测试将顺利运行。这个错误的原因是什么?我怎么修?

    1 回复  |  直到 6 年前
        1
  •  1
  •   DublinDev    6 年前

    未包含在IT块中的代码将被提升到顶部,并在任何IT块启动之前运行,这意味着您的测试在那时可能不会处于预期状态。尝试再次编写代码,但要使用IT中的计数块。

    require('..\\waitAbsent.js');
    require("../node_modules/jasmine-expect/index.js");
    var EC = protractor.ExpectedConditions;
    
    describe('Demo_Test For count', function () {  
        beforeAll(function () {
            browser.driver.manage().window().maximize();
            browser.get(globalVariables.loginMain);
            globalVariables.Email_Input_box.sendKeys(globalVariables.Demo_User);
            globalVariables.Password_Input_Box.sendKeys(globalVariables.Demo_PWD);
            globalVariables.Submit_Button.click();
            browser.wait(EC.invisibilityOf(globalVariables.Submit_Button), 25000, 'submit button is not disappearing yet');
        });
    
    
        it('Dashboard Title Validation', function () {
    
            expect(globalVariables.ESY_DB_Label.isDisplayed());
            expect(globalVariables.ESY_DB_Label.getText()).toEqual('HomePage')
    
        });
    
        it("1+1", function () {
           //count block
           globalVariables.tableData_Dashboard.all(by.tagName("tr")).count().then(function (Count) {
               console.log('\n the count of the rows are ' + Count + '\n');
           });
           //count block end
    
            let i = 1;
            let j = i + i;
            expect(j).toBe(2);
    
        })
    });