2017-05-08 4 views
1

7.6より上のnode.jsバージョンを更新しました。また、ES6.Iも使用しています。エラーメッセージが添付されています.Jasminとjavascriptを使用してtest.Withoutを書き込んでいます。なぜエラー以下来ている.ANYのヘルプを把握することができ、高分裂器でasync-awaitを使用する方法は?

My code is :- 
    SELENIUM_PROMISE_MANAGER: false, 
    describe("testing login functionalties", function() { 

    it("entering the text", async function() { 

    browser.get("https://weather.com/en-IN"); 
    //console.log('ddd') 
    browser.ignoreSynchronization= true; 
    element(by.xpath("//button[@class='user-login']")).click() 
    //browser.ignoreSynchronization= true; 
    console.log('ddd') 
    element(by.xpath("//input[@type='email']")).sendKeys("[email protected]"); 
    element(by.xpath("//input[@type='password']")).sendKeys("xxxxx"); 
    var a= element(by.xpath("//button[@class='btn btn-disabled sign-button login-button']")); 
    await a.getText(); 
    console.log(a); 
    a.click(); 


}); 

を})apppreciatedされます。

And the error i am getting is:- 
    /usr/local/Cellar/node/7.9.0/bin/node /usr/local/lib/node_modules/protractor/built/cli.js /Users/amrit/WebstormProjects/E2E/conf.js 
    (node:13230) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead. 
    (node:13230) DeprecationWarning: `DEBUG_FD` is deprecated. Override `debug.log` if you want to use a different log function (https://git.io/vMUyr) 
    [16:03:41] I/local - Starting selenium standalone server... 
    [16:03:41] I/launcher - Running 1 instances of WebDriver 
    [16:03:42] I/local - Selenium standalone server started at http://10.101.23.28:60360/wd/hub 
    Started 
    F 

    Failures: 
    1) testing login functionalties encountered a declaration exception 
     Message: 
     Error: async function() { 

       browser.get("https://weather.com/en-IN"); 
       //console.log('ddd') 
       browser.ignoreSynchronization= true; 
       element(by.xpath("//button[@class='user-login']")).click() 
       //browser.ignoreSynchronization= true; 
       console.log('ddd') 
       element(by.xpath("//input[@type='email']")).sendKeys("[email protected]"); 
       element(by.xpath("//input[@type='password']")).sendKeys("xxxxx"); 
       var a= element(by.xpath("//button[@class='btn btn-disabled sign-button login-button']")); 
       await a.getText(); 
       console.log(a); 
       a.click(); 


      } is not a function 
     Stack: 
     Error: async function() { 

       browser.get("https://weather.com/en-IN"); 
       //console.log('ddd') 
       browser.ignoreSynchronization= true; 
       element(by.xpath("//button[@class='user-login']")).click() 
       //browser.ignoreSynchronization= true; 
       console.log('ddd') 
       element(by.xpath("//input[@type='email']")).sendKeys("[email protected]"); 
       element(by.xpath("//input[@type='password']")).sendKeys("xxxxx"); 
       var a= element(by.xpath("//button[@class='btn btn-disabled sign-button login-button']")); 
       await a.getText(); 
       console.log(a); 
       a.click(); 


      } is not a function 
      at validateFunction (/usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:30:11) 
      at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:116:16 
      at Suite.<anonymous> (/Users/amrit/WebstormProjects/E2E/Describe.js:8:5) 
      at Object.<anonymous> (/Users/amrit/WebstormProjects/E2E/Describe.js:6:1) 
      at Module._compile (module.js:571:32) 
      at Object.Module._extensions..js (module.js:580:10) 
      at Module.load (module.js:488:32) 

    1 spec, 1 failure 
    Finished in 0.011 seconds 
    [16:03:44] I/local - Shutting down selenium standalone server. 
    [16:03:44] I/launcher - 0 instance(s) of WebDriver still running 
    [16:03:44] I/launcher - chrome #01 failed 1 test(s) 
    [16:03:44] I/launcher - overall: 1 failed spec(s) 
    [16:03:44] E/launcher - Process exited with error code 1 

    Process finished with exit code 1 
+0

'it'の中に 'async'という単語を削除します。 –

+0

次にasync-awaitの使い方は? –

+0

非角ページの場合、 'browser.ignoreSynchronization = true;'がトリックを行います。要素を待つ必要がある場合。あなたは 'browser.sleep(1000)'を使う必要があります。 –

答えて

-1

私のコメントに記載されているように、単語asyncを削除します。
browser.ignoreSynchronizationをtrueに設定すると、非角度ページのトリックが実行されます。

また、コードを更新すると、getTextで失敗する可能性があります。 また、私はxpathのファンではありません。代わりにby.cssを使うことをお勧めします。

describe('testing login functionalties', function() { 
    it("entering the text", function() { 
     browser.get("https://weather.com/en-IN"); 

     browser.ignoreSynchronization= true; 
      element(by.css('[@class="user-login"]')).click() 

      console.log('ddd') 
      element(by.css('[type="email"]')).sendKeys('[email protected]'); 
      element(by.css('[type="password"]')).sendKeys('xxxxx'); 
      var a = element(by.css('.btn.btn-disabled.sign-button.login-button')); 
      a.getText().then(function(tmpText) { 
      console.log(tmpText); 
     }); 
      a.click(); 
    }); 
}); 
+0

答えを下げました。彼はAngular以外のページを要求していません。問題は、[async-await](http://rossboucher.com/await/#/)を分度器と組み合わせて使用​​する方法です。 – wswebcreation

+0

私は別の解決法を提供しています。私はそれがすべての答えをdownvoteするのに適切ではないと思いますあなたの好みに合っていない。彼らがそれを使うかどうかは彼らの選択です。 –

+0

あなたは質問を読むべきです、質問は '..aysnc-a-wit working fine -...'ですので、あなたの答えは質問に関連していません – wswebcreation

1

クイックテストを実行してエラーを再現できました。ちょっとしたデバッグでは、問題はジャスミン(少なくとも分裂器5.1.1に同梱されているもの)と思われます。私はasync-awaitをインストールして、Mochaをインストールし、それをconfigのframeworkとして選択することで動作させることができました。

関連する問題