2

I want to do something every time I click an element.

So when I call click

I.click(locator);

Instead of calling webdriver click function, I want it to call my override which I've added to steps_file.js

click(locator){

    // do something first
    console.log('something');

    // finally click the element
    this.helpers["WebDriverIO"].browser.click(locator);
}

I've got 2 problems:

  1. My click function is getting ignored. It still clicks the element normally. I don't see any log "something"
  2. steps_file.js doesn't seem to have access to helpers. this.helpers is undefined
Dingredient
  • 2,011
  • 17
  • 46

1 Answers1

-2

Why you need override standard function? I think will be much easier and effective just create a custom step called "clickOn" and use it instead of "click". Inside custom steps you can do whatever you want.