简体   繁体   English

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

[英]Protractor - adding a count function returns “”both angularJS testability and angular testability are undefined…" error

I am trying to create loop for the button clicks on the app. 我正在尝试为应用程序上的按钮单击创建循环。 to do so I need to count the number of rows in the table where the buttons are present. 为此,我需要计算存在按钮的表中的行数。 So I created this script: 所以我创建了这个脚本:

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);

})

});

When I run this script, all the tests fails , even the 2nd one where I just added 1+1! 当我运行此脚本时,所有测试都将失败,甚至第二个测试我刚刚添加了1 + 1! The log is as follows: 日志如下:

  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)

But if I comment out the block for count , the test runs smoothly. 但是,如果我注释掉该块以进行计数,则测试会顺利进行。 What is the cause of this error? 此错误的原因是什么? How can I fix it? 我该如何解决?

Code not contained within an it block will be hoisted to the top and run before any it block has started, meaning your test will likely not be in the expected state at that time. 未包含在it块中的代码将被提升到顶部并在任何it块开始之前运行,这意味着您的测试当时可能不在预期的状态。 Try writing your code once more but with your count block within an it. 尝试再次编写代码,但要在其中包含您的count块。

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);

    })
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 量角器3.1.1 + Angular2:无法找到元素的可测试性 - Protractor 3.1.1 + Angular2: Could not find testability for element 如何构造可测试性的Lambda代码 - How to structure lambda code for testability 在AngularJS中,为什么将表示逻辑(例如jQuery)放入控制器会对可测试性产生负面影响? - In AngularJS, why does putting presentation logic (such as jQuery) into controllers negatively affect testability? JavaScript(量角器)中函数的值返回未定义 - value of a function in JavaScript(protractor) returns as undefined 使用javascript / coffeescript进行依赖注入以帮助测试 - Dependency Injection with javascript / coffeescript to aid testability 实例化单个对象,同时保持可测试性的模式 - Pattern for instantiating a single object, while maintaining testability Angular - 在 eventlistener 函数中调用服务函数返回未定义的错误 - Angular - calling service function inside eventlistener function returns undefined error JavaScript错误:未定义'Angular'-AngularJS - JavaScript error: 'angular' is undefined - AngularJS AngularJS / Protactor:使用角度种子基本应用程序运行量角器时出错? - AngularJS /Protactor : Error while running the protractor with the angular seed basic app? 量角器函数返回未定义? - Protractor function returning undefined?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM