drag-mock icon indicating copy to clipboard operation
drag-mock copied to clipboard

Using it with webdriver.io from a test

Open prewk opened this issue 9 years ago • 7 comments

Hi, I'm unsure on how to add the functionality from inside a test.

dragMock.extendWebdriver(webdriver); and dragMock.loadLibrary(webdriver); assumes I have a webdriver, but afaik I only have a browser?

const dragMock = require('drag-mock');

describe('Something', function() {
  it('should drag n drop', function() {
    // How do I extend and load it into the webdriver here?
    dragMock.extendWebdriver(browser);
    dragMock.loadLibrary(browser);

    browser.dragStart('.Something');
    // ^-causes a "browser.dragStart is not a function" error
  });
});

Do I add it to the webdriver in one of the lifecycle hooks in wdio.conf.js? I can't find the right method or argument there, unfortunately.

prewk avatar Oct 18 '16 19:10 prewk

Are you using webdriver.io? Then I suggest using the before() hook in your test file. And you also have the webdriver object: http://webdriver.io/guide.html

If you are not using webdriver, you shouldn't have to care about extendWebdriver() and loadLibrary().

Hope that helps!

andywer avatar Oct 19 '16 07:10 andywer

Thanks, I am using webdriver.io, and that guide (scroll to bottom) is what prompted me to use The browser object which seems to be the webdriver instance.

However, running the following code:

dragMock.extendWebdriver(browser);
dragMock.loadLibrary(browser);

..and subsequently:

browser.dragStart('.Something');

Causes a browser.dragStart is not a function crash in the test. Using the before() hook or not, it seems if I only have one test, and it crashes like that, something else is amiss, don't you think?

prewk avatar Oct 19 '16 08:10 prewk

Ahhh, now we are on the same page.

I fear that more recent webdriver versions have a different API than one and a half years ago when I wrote this... :-/ Maybe it's a minor issue, but currently I haven't got the time to look into that, sorry.

If you are able to make it work, please share it and we can share the knowledge here. If you decide to go for a different tool, let me know, too and I might add it as a possible alternative to the README :)

andywer avatar Oct 19 '16 08:10 andywer

I see, thank you for your assessment anyways :)

If I come up with something I'll get back to you, I'll leave this issue open, then.

prewk avatar Oct 19 '16 08:10 prewk

Could you solve that issue? I have exact the same problem...

jaqua avatar Nov 03 '16 18:11 jaqua

Sorry, not yet.

prewk avatar Nov 03 '16 19:11 prewk

Added a line to the README to at least warn users: https://github.com/andywer/drag-mock#webdriverio-integration

andywer avatar Feb 22 '17 14:02 andywer