Inspect WebdriverIO spec variables

2019-08-09 17:39发布

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?

2条回答
Summer. ? 凉城
2楼-- · 2019-08-09 18:17

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.

查看更多
可以哭但决不认输i
3楼-- · 2019-08-09 18:40

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
},
查看更多
登录 后发表回答