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

これはコードです。分度器コンソールが要素またはコンソールと異なって表示されます

分度器コンソールは、私がelementorコンソールでこれを行うとき、それが出力として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"]' } } } 

BTを示しています。 (それはセルで、私はセル値を求めて2です)

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

私は間違っていますか?

私はさまざまな組み合わせを試みましたが、ddは機能しません。私はこの

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

を行うとき、私はそれが出力についてだと思う

ので、それは私はそれが理由ITIS文字列だと思うので、私はint型に変換するのにNumberを使用しなかったが

Expected '1' to be 1. 

を語りますそれは

のために言う

Expected NaN to be 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); 

ため

も何をすべきかそう

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

は、それが与えることはありません、あなたはgetText()を記録慰めるかのように、すべての分度器の

Expected NaN to be 1. 
+0

:テキストを取得するためにinorderを、次のようなthen function()を使用する必要があります.first()。getText())。toBe( '1'); ' –

答えて

1

まず、非同期であると言いますテキストが約束です。あなたは、単に(element.all( by.css( 'TD [データ-ヘッダーテキスト= "製品"]')) `を使用期待でき

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

最初にすべてオフです。残りの部分はどこにありますか?ご覧のとおり、私も期待していました。非同期ではありません。問題は価値が本当に来ていないことです。 – mark

+0

分度器の 'expect'はそれを処理するようにプログラムされています。したがって、たとえそれが非同期であっても、同期呼び出しであるかのように表示されます –

関連する問題