protractor console shows different than elementor console

83 views Asked by At
element.all(by.css('td[data-header-text="products"]')).first()
                productCountInTask = taskPage.productCountInTask.getText();
                console.log("yyyy",taskPage.productCountInTask.getText());

this is code.

protractor console shows a long text

yyyy { ptor_: 
   { setFileDetector: [Function],
     launchApp: [Function],
     controlFlow: [Function],
     schedule: [Function],
     getSession: [Function],
     getCapabilities: [Function],
     quit: [Function],
     actions: [Function],
     touchActions: [Function],
     executeScript: [Function],
     executeAsyncScript: [Function],
     call: [Function],
     wait: [Function],
     sleep: [Function],
     getWindowHandle: [Function],
     getAllWindowHandles: [Function],
     getPageSource: [Function],
     close: [Function],
     getCurrentUrl: [Function],
     getTitle: [Function],
     findElementInternal_: [Function],
     findDomElement_: [Function],
     findElementsInternal_: [Function],
     takeScreenshot: [Function],
     manage: [Function],
     switchTo: [Function],
     driver: 
      { session_: [Object],
        executor_: [Object],
        flow_: [Object],
        fileDetector_: null },
     element: { [Function] all: [Function] },
     '$': [Function],
     '$$': [Function],
     baseUrl: 'http://.qa..com:8080',
     rootEl: 'body',
     ignoreSynchronization: false,
     getPageTimeout: 10000,
     params: {},
     ready: 
      { closure_uid_815821442: 20,
        flow_: [Object],
        stack_: null,
        parent_: null,
        callbacks_: null,
        state_: 'fulfilled',
        handled_: true,
        value_: null,
        queue_: null },
     plugins_: 
      { pluginConfs: [],
        pluginObjs: [],
        assertions: {},
        resultsReported: false },
     resetUrl: 'data:text/html,<html></html>',
     trackOutstandingTimeouts_: true,
     mockModules_: [ [Object], [Object], [Object] ],
     allScriptsTimeout: 240000,
     getProcessedConfig: [Function],
     forkNewDriverInstance: [Function],
     restart: [Function] },
  parentElementArrayFinder: 
   { ptor_: 
      { setFileDetector: [Function],
        launchApp: [Function],
        controlFlow: [Function],
        schedule: [Function],
        getSession: [Function],
        getCapabilities: [Function],
        quit: [Function],
        actions: [Function],
        touchActions: [Function],
        executeScript: [Function],
        executeAsyncScript: [Function],
        call: [Function],
        wait: [Function],
        sleep: [Function],
        getWindowHandle: [Function],
        getAllWindowHandles: [Function],
        getPageSource: [Function],
        close: [Function],
        getCurrentUrl: [Function],
        getTitle: [Function],
        findElementInternal_: [Function],
        findDomElement_: [Function],
        findElementsInternal_: [Function],
        takeScreenshot: [Function],
        manage: [Function],
        switchTo: [Function],
        driver: [Object],
        element: [Object],
        '$': [Function],
        '$$': [Function],
        baseUrl: 'http://.qa..com:8080',
        rootEl: 'body',
        ignoreSynchronization: false,
        getPageTimeout: 10000,
        params: {},
        ready: [Object],
        plugins_: [Object],
        resetUrl: 'data:text/html,<html></html>',
        trackOutstandingTimeouts_: true,
        mockModules_: [Object],
        allScriptsTimeout: 240000,
        getProcessedConfig: [Function],
        forkNewDriverInstance: [Function],
        restart: [Function] },
     getWebElements: [Function],
     actionResults_: 
      { closure_uid_815821442: 7800,
        flow_: [Object],
        stack_: null,
        parent_: [Object],
        callbacks_: null,
        state_: 'pending',
        handled_: false,
        value_: undefined,
        queue_: null },
     locator_: 
      { using: 'css selector',
        value: 'td[data-header-text="products"]' } },
  then: [Function],
  elementArrayFinder_: 
   { ptor_: 
      { setFileDetector: [Function],
        launchApp: [Function],
        controlFlow: [Function],
        schedule: [Function],
        getSession: [Function],
        getCapabilities: [Function],
        quit: [Function],
        actions: [Function],
        touchActions: [Function],
        executeScript: [Function],
        executeAsyncScript: [Function],
        call: [Function],
        wait: [Function],
        sleep: [Function],
        getWindowHandle: [Function],
        getAllWindowHandles: [Function],
        getPageSource: [Function],
        close: [Function],
        getCurrentUrl: [Function],
        getTitle: [Function],
        findElementInternal_: [Function],
        findDomElement_: [Function],
        findElementsInternal_: [Function],
        takeScreenshot: [Function],
        manage: [Function],
        switchTo: [Function],
        driver: [Object],
        element: [Object],
        '$': [Function],
        '$$': [Function],
        baseUrl: 'http://.qa..com:8080',
        rootEl: 'body',
        ignoreSynchronization: false,
        getPageTimeout: 10000,
        params: {},
        ready: [Object],
        plugins_: [Object],
        resetUrl: 'data:text/html,<html></html>',
        trackOutstandingTimeouts_: true,
        mockModules_: [Object],
        allScriptsTimeout: 240000,
        getProcessedConfig: [Function],
        forkNewDriverInstance: [Function],
        restart: [Function] },
     getWebElements: [Function],
     actionResults_: 
      { closure_uid_815821442: 7800,
        flow_: [Object],
        stack_: null,
        parent_: [Object],
        callbacks_: null,
        state_: 'pending',
        handled_: false,
        value_: undefined,
        queue_: null },
     locator_: 
      { using: 'css selector',
        value: 'td[data-header-text="products"]' } } }

bt when i do this in elementor console, it shows 2 as output. (it is a cell and i want cel value and it is 2)

element.all(by.css('td[data-header-text="products"]')).first().getText()    2

what am i doing wrong?

i tried different combinations but dd not work.

i think it is about output so when i do this

     expect(element.all(
by.css('td[data-header-text="products"]')).first().getText()).toBe(1);

it says

 Expected '1' to be 1.

i think it is because itis string , so i used Number to convert to int but did not work

    Expected NaN to be 1.

it says for

  expect(Number(element.all(by.css('td[data-header-text="products"]')).first().getText())).toBe(1);

so what to do

also for

                var a = parseInt(element.all(by.css('td[data-header-text="products"]')).first().getText());

            //checking if there is only one product
            expect(a).toBe(1);

says

Expected NaN to be 1.
1

There are 1 answers

2
radio_head On

First of all protractor is asynchronous, so if you console log getText(), it will not give the text but a promise. Inorder to get the text, you should use then function() like:

taskPage.productCountInTask.getText().then(function(text){
   console.log('yyyyy', text);    
});