Skip to content
This repository was archived by the owner on Dec 18, 2019. It is now read-only.
This repository was archived by the owner on Dec 18, 2019. It is now read-only.

How to extend Element class method in TypeScript using webdriverio? #29

@christian-bromann

Description

@christian-bromann

From @draganrakas on March 12, 2019 15:45

Stack: TypeScript, WDIO, Cucumber

We are having an issue with the click() functionality not working on buttons in SauceLabs only, and on FireFox only. We tested other combinations (local, CI, Docker, etc.) and our tests work on both FireFox and Chrome for all of those combinations. However, on SauceLabs, clicking a button in FireFox is very flaky.

We have tested a JavaScript workaround that works, on SauceLabs on FireFox, and as a result, we would like the element click() method to behave differently depending if the browser capability is either chrome or firefox.

To do this, we would like to extend the WebDriver Element, and override the click method with our own. Basically, use super.click() for chrome, and our own click for firefox.

Currently, our BasePage exports this, which is just a typedef that the page objects use:
export type WDIOElement = WebdriverIO.Client<WebdriverIO.RawResult<WebdriverIO.Element>>

Instead of this, we would like to create a WDIOElement definition that implements the WebdriverIO.Client<WebdriverIO.RawResult<WebdriverIO.Element>> interface, re-implements click() and export that instead.

Is this even possible? What would be the recommended way to do this?
If this is pretty bad practice, is there something better we could do?

Thanks!

Copied from original issue: webdriverio/webdriverio#3719

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions