【问题标题】:Webdriverio using async/await - What is recommended? [closed]Webdriverio 使用 async/await - 推荐什么? [关闭]
【发布时间】:2019-05-29 05:18:40
【问题描述】:

我正在使用WebdriverIO 运行我的功能测试。即使没有async/await,我也可以通过 WebdriverIO 测试。但我读过一些文章,async/await 是编写 javascript 来处理 Promise 的最佳方式。

我是 Javascript 新手,对 Promise 很迷茫。在 WebdriverIO 中编写代码的最佳方式是什么(是否使用异步/等待 | 例如:在配置中关闭同步并使用它?

wdio.conf.js 配置文件声明如下:

// By default WebdriverIO commands are executed in a synchronous way using
// the wdio-sync package. If you still want to run your tests in an async 
// e.g. using promises you can set the sync option to false.
//
sync: true

【问题讨论】:

  • 请在问题中添加您的代码
  • 我重新表述了我的问题。我想弄清楚is using async/await in webdriverio the best way of coding by turning sync off in configuration file or not using it by turning sync on in that file
  • 不要相信你读过的每一篇文章。如果您来自传统的顺序编程环境,请继续使用sync: true。否则,如果你想在 JS 和使用 Promises 方面表现出色,那就去sync: false。这只是味道...... w/e 漂浮在你的船

标签: javascript webdriver-io


【解决方案1】:

WebdriverIO 仍然在后台使用 async/await,它只是为您处理它。我绝对推荐使用“同步”模式,因为它可以减少测试的冗长。

【讨论】:

猜你喜欢
  • 2018-12-21
  • 1970-01-01
  • 2018-09-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-01-02
相关资源
最近更新 更多