2017-04-10 5 views
0

私はuseingナイトウォッチいくつかの自動テストを行いたい:nightwatch.jsでexecuteAsyncを使用するには?

module.exports = { 
    'Demo asynchronous' : function(client){ 
     client.url(client.launchUrl); 
     client.executeAsync(function(data, done) { 
      someAsyncOperation(function() { 
       client.setValue('#PoiSearch', data); 
       client.click('#POISearchButton'); 
       done(true); 
     }); 
     }, ['hotle'], function(result) { 
      client.expect.element('#Map div[name*="mark"]').to.be.present; 
     }); 
    } 
} 

は、私はちょうどよりも、入力する単語をしたい:

this.demoTest = function (browser) { 
    browser.executeAsync(function(data, done) { 
     someAsyncOperation(function() { 
     done(true); 
    }); 
    }, [imagedata], function(result) { 
     // ... 
    }); 
}; 

しかし、私はexecuteAsyncを使用する方法がわからない、流れは私のコードですその結果、私はDOMに特別な要素があることを知りたいのですが、executeAsyncの使い方は分かりません。

答えて

1

executeAsyncに渡す関数は、コントロールしているブラウザのjavascriptコンソールにあるように実行されます(ノード/セレンのコンテキストでは他のすべてが実行されます)。 executeAsync関数の内部client変数

あなたはナイトウォッチAPIを使用してこれらのフィールドを埋めるために待ちたい場合は、より多くのような何かができます。

`` `

module.exports = { 
    'Demo asynchronous' : function(client){ 
     client.url(client.launchUrl); 
     client.executeAsync(function(data, done) { 
      // start executing in the browser, no access to outside variables 
      someAsyncOperation(function() {     
       done(true); 
      });    
     }); 
     // end executing in the browser, back in the node context 
     client.setValue('#PoiSearch', 'hotle'); 
     client.click('#POISearchButton');; 
     client.expect.element('#Map div[name*="mark"]').to.be.present; 
    } 
} 

`` `

関連する問題