element icon indicating copy to clipboard operation
element copied to clipboard

Howto needed to debug an Element script using Visual Studio Code on Mac

Open peterwake opened this issue 5 years ago • 3 comments

I am trying to debug an Element script using Visual Studio Code on my Mac.

I'd like a tutorial on how to set up VS Code so that I can put a breakpoint inside a 'step' in VS Code, so that when my code like

let button = By.css('#wpProQuiz_3 input[name="next"]')
await browser.wait(Until.elementIsVisible(button))

fails .. I can work out what's gone wrong. Otherwise it feels just like I am fumbling around in the dark. I can see the button I want to click in the headless browser but it won't find it.

It feels like element run is a wrapper around my typescript file, but I can't work out what is it doing.

peterwake avatar Sep 29 '20 07:09 peterwake

Hi @peterwake , you just need to add the keyword debugger likes the following image Then it should work image

phileba avatar Oct 12 '20 03:10 phileba

Are you using a launch.json in vscode to make this work?

DanHamlin-LifeTime avatar Oct 28 '20 14:10 DanHamlin-LifeTime

Are you using a launch.json in vscode to make this work?

That's correct @DanHamlin-LifeTime . Please add these configurations to the launch.json file in VSCode:

{
  "version": "1.3.8",
  "configurations": [
    {
      "name": "debug",
      "type": "node",
      "request": "launch",
      "args": [
        "/usr/local/bin/element",
        "run",
        "./test.ts",
        "--devtools",
        "--debug"
      ],
    }
  ]
}

sonnguyenmau avatar Nov 03 '20 07:11 sonnguyenmau