Inspect WebdriverIO spec variables

别等时光非礼了梦想. 提交于 2019-12-13 01:54:21

问题


I figured out, that I can use browser.pause(); to stop the execution of the browser and inspect its current variables, but how do I inspect the variables of my WebdriverIO test source?

Of course I could call console.log() if I would like to know a value. But for every try I would have to restart the complete test suite, or I would need to comment every other test.

Instead, I would ideally like to stop the execution in one line and inspect all available variables.

Does somebody has a solution for that, or an other idea?


回答1:


This is not the matter of webdriver-io, but the IDE you are using. What you are looking for is a remote debugging feature of an IDE. I've been doing that with Webstorm successfully.

Have a look at this video on how to run setup test runner in Webstorm.




回答2:


For people coming here in hopes of an easier debug process of their WebdriverIO test cases, take a look at the .debug() command.

It doesn't do exactly what @Sandro was looking for, but it offers an alternative to changing your text-editor for a fancy, lumbering IDE:

  • stops the execution of your current running test (just add browser.debug() after the line you want your "breakpoint");
  • turns your terminal into a read-eval-print-loop;
  • grants you access to the browser object in the state in which it is found, alongside all the other API commands.

Drawbacks:

  • you will have to "recreate" some of the setup until that point (variables and contained values are not accessible from the REPL interface).

!Note: If you are using the WDIO testrunner, make sure you increase the timeout property of your test framework your are using (e.g. Mocha, Cucumber, or Jasmine) in order to prevent the continuation due to a test timeout.

mochaOpts: {
    ui: 'bdd',
    timeout: 9999999
},


来源:https://stackoverflow.com/questions/29409230/inspect-webdriverio-spec-variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!