我已經更新了我的node.js版本7.6以上,我使用ES6.I也附加了錯誤消息。我使用茉莉花和JavaScript寫測試。沒有aysnc - 等待其工作正常..我不是能夠找出爲什麼下面的錯誤來了。任何幫助將非常apppreciated如何在量角器中使用異步等待?
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();
});
});
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
在'it'裏面刪除'async'這個詞。 –
那麼如何使用async-await? –
對於非角度頁面'browser.ignoreSynchronization = true;'會有效。如果你需要等待一個元素。您需要使用'browser.sleep(1000)' –