Struggling to keep a reference to table cells at runtime

I am trying to read the values ​​from the table cells in a row to check the values ​​corresponding to the expected ones.

I was faced with a situation where the protractor cannot get the text of the specific cells that interest me, because it cannot find the cells that I request.

Here are my test suite steps:

beforeAll(function() {
    common.journeyValidationBtn.click();
    helper.waitForUrlToContain('journey-validation');
    helper.waitForElementToHide(common.spinner);
    common.fabBtn.click();
    helper.waitForPresenceOf(common.calculateBtn);
    common.runCalculation(secondaryPeriod);
    helper.waitForPresenceOf(common.fabBtn, 30000);
    helper.waitForElementToHide(common.spinner);
    common.selectComparisonPeriod(initialPeriod);
    helper.waitForTableRows(page.reimbursementCalculations).then(function() {
        console.log('*** Table Rows Found - promise resolved ***');
        page.reimbursementCalculations.count().then(function(count){
            console.log('*** Number of Table Rows Found - ' + count + ' ***');
            row = page.reimbursementCalculations.first();
            cells = row.all(by.css('td'));
            cells.count().then(function(cellCount){
                console.log('*** Number of Table Cells Found - ' + cellCount + ' ***');
                cells.get(0).getText().then(function(text){
                    console.log('*** First Table Cell Text - ' + text + ' ***');
                });
            });
        });
    }, function(reason){
        console.log('*** Table Rows Not Found - promise rejected ***');
        console.log(reason);
    });
});
it('Then I should get more than one cell returned', function() {
    expect(cellCount.count()).toBeGreaterThan(0);
});

When I run the test, I see some Jasmine timeout errors, followed by a crash for my wait, when it cannot call count () in my cell variable, which is assigned in the beforeAll block. Perhaps this timeout is related to what I see, but I'm trying to debug this further.

[12:20:01] I/testLogger - [chrome #01-6] PID: 9609
[chrome #01-6] Specs: /var/jenkins/workspace/project_x/test/e2e/features/featureA/workflow/SW0005.spec.js
[chrome #01-6] 
[chrome #01-6] [12:18:56] I/direct - Using ChromeDriver directly...
[chrome #01-6] Started
[chrome #01-6] *** Comparison period selected ***
[chrome #01-6] [12:19:07] W/element - more than one element found for locator By(css selector, .spinnerContainer) - the first result will be used
[chrome #01-6] [12:19:41] W/element - more than one element found for locator By(css selector, .spinnerContainer) - the first result will be used
[chrome #01-6] *** Table Rows Found - promise resolved ***
[chrome #01-6] *** Number of Table Rows Found - 1 ***
[chrome #01-6] *** Number of Table Cells Found - 11 ***
[chrome #01-6] *** First Table Cell Text - blaa ***
[chrome #01-6] A Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] [31mF[0mA Jasmine spec timed out. Resetting the WebDriver Control Flow.
[chrome #01-6] Failures:
[chrome #01-6]   Message:
[chrome #01-6] [31m    Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.[0m
[chrome #01-6]   Stack:
[chrome #01-6]     Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
[chrome #01-6]         at ontimeout (timers.js:365:14)
[chrome #01-6]         at tryOnTimeout (timers.js:237:5)
[chrome #01-6]         at Timer.listOnTimeout (timers.js:207:5)
[chrome #01-6]   Message:
[chrome #01-6] [31m    Failed: Cannot read property 'count' of undefined[0m
[chrome #01-6]   Stack:
[chrome #01-6]     TypeError: Cannot read property 'count' of undefined

, , , ( 11 ), , undefined . my beforeAll, , , undefined .

, .

, - , - ?

+4
1

Jasmine beforeAll, beforeEach, afterEach, afterAll it timeout / . , -

, , - , JavaScript.

:

beforeAll(function() {
    //all your test code

    }); //don't add ", function(reason){etc});
});
it('Then I should get more than one cell returned', function() {
    expect(cells.count()).toBeGreaterThan(0);
});

, "count", :

cells = row.all(by.css('td'));
cells.count().then(function(count2){ //Here the "count" is missing
    console.log('*** Number of Table Cells Found - ' + count2 + ' ***');

UPDATE

, , .

, , " " count "" undefined "". page.reimbursementCalculations .

:

console.log('*** Number of Table Rows Found - ' + count + ' ***');
console.log('*** Number of Table Cells Found - ' + count + ' ***');
+2

Source: https://habr.com/ru/post/1689310/


All Articles