量角器控制台显示与elementor控制台不同

时间:2017-01-05 09:11:39

标签: protractor elementor

modular css

这是代码。

量角器控制台显示长文本

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

bt当我在elementor控制台中执行此操作时,它显示2作为输出。 (这是一个细胞,我想要cel值,它是2)

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"]' } } }

我做错了什么?

我尝试了不同的组合,但dd不起作用。

我认为这是关于输出所以当我这样做时

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

它说

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

我认为这是因为它是字符串,所以我使用 Expected '1' to be 1. 转换为int但不起作用

Number

它代表

    Expected NaN to be 1.

所以该怎么做

也适用于

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

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

1 个答案:

答案 0 :(得分:1)

首先,量角器是异步的,因此如果您控制日志getText(),它将不会给出文本而是提供承诺。为了获得文本,您应该使用then function()之类的:

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