首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >量角器-添加count函数返回“”angularJS可测试性和角度可测试性均未定义...“错误

量角器-添加count函数返回“”angularJS可测试性和角度可测试性均未定义...“错误
EN

Stack Overflow用户
提问于 2019-01-17 00:21:56
回答 1查看 42关注 0票数 0

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

代码语言:javascript
复制
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的第二个测试也是如此!日志如下:

代码语言:javascript
复制
  Student Enrollment Page Content Validation 1+1
  Message:
    Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined.  This could be either because this is a non-angular page or because your test involves client-side
 navigation, which can interfere with Protractor's bootstrapping.  See https://github.com/angular/protractor/issues/2643 for details"
  Stack:
    Error: Error while waiting for Protractor to sync with the page: "both angularJS testability and angular testability are undefined.  This could be either because this is a non-angular page or because your test involves client-side
 navigation, which can interfere with Protractor's bootstrapping.  See https://github.com/angular/protractor/issues/2643 for details"
        at runWaitForAngularScript.then (C:\ESY_Desktop_V_2\node_modules\protractor\built\browser.js:463:23)
        at ManagedPromise.invokeCallback_ (C:\ESY_Desktop_V_2\node_modules\selenium-webdriver\lib\promise.js:1376:14)
        at TaskQueue.execute_ (C:\ESY_Desktop_V_2\node_modules\selenium-webdriver\lib\promise.js:3084:14)
        at TaskQueue.executeNext_ (C:\ESY_Desktop_V_2\node_modules\selenium-webdriver\lib\promise.js:3067:27)
        at asyncRun (C:\ESY_Desktop_V_2\node_modules\selenium-webdriver\lib\promise.js:2927:27)
        at C:\ESY_Desktop_V_2\node_modules\selenium-webdriver\lib\promise.js:668:7
        at process._tickCallback (internal/process/next_tick.js:68:7)

但是如果我注释掉count的代码块,测试就会顺利运行。此错误的原因是什么?我怎么才能修复它?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-17 00:58:20

不包含在it块中的代码将被提升到顶部,并在任何it块启动之前运行,这意味着您的测试很可能在那时不会处于预期状态。试着再写一次你的代码,但是把你的count块放在it中。

代码语言:javascript
复制
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);

    })
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54221237

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档