gemini-testing / gemini

💀💀💀[DEPRECATED] Use hermione
https://github.com/gemini-testing/hermione
MIT License
1.5k stars 149 forks source link

Actions object in before is not the same as in capture #120

Open dentuzhik opened 9 years ago

dentuzhik commented 9 years ago

This makes currying of helpers, that depend on actions impossible.

function paste(actions, find) {
    return function(input, value) {
        // do stuff with actions.sendKeys
    }
}

gemini.suite('foo', function(suite) {
    suite
        .setUrl('bar')
        .setCaptureElement('.baz')
        .before(function(actions, find) {
             this.paste = paste(actions, find);
             this.tmpActions = actions;
        })
        .capture('paste-text', function(actions, find) {
            // Wont' work
            this.paste(find('.baz__input'), '123');
            // Will work
            paste(actions, find)(find('.baz__input'), '123');
            // Will fail
            console.assert(this.tmpActions === actions, 'Not equal!');
        });
});

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

SevInf commented 9 years ago

Making it same instance is not very easy task as for now. However, I thought about making actions object extendable, maybe it will help you. What do you think about something like this (it won't work now, its just API proposal):

gemini.Actions.extend({
    paste: function(input, value) {
        this.sendKeys(...)
    }
})

gemini.suite('foo', function(suite) {
    suite
        .setUrl('bar')
        .setCaptureElement('.baz')
         .capture('paste-text', function(actions, find) {
            actions.paste('.baz__input', '123')
        });
});
dentuzhik commented 9 years ago

I like the idea of extendable actions, and for the purpose of the example provided they are more natural However I still think that it will be more convenient, if actions would be the same object, or at least currying in a way example does won't fail to perform an action.

If it's not possible to fix in the near future it should be at least outlined in docs, because it will cause obvious confusion when facing in the wild.

dentuzhik commented 9 years ago

Btw, is there a clean way to do copy paste in webdriver/gemini, without using platform-dependent key-bindings and temporary dom elements?

SevInf commented 9 years ago

Btw, is there a clean way to do copy paste in webdriver/gemini, without using platform-dependent key-bindings and temporary dom elements?

No, as far as I know, the only way to perform copy-paste is using sendKeys.

shuhrat commented 9 years ago

No, as far as I know, the only way to perform copy-paste is using sendKeys.

What about adding some helpers for those purposes? it would be great! @dentuzhik Denis, what about PR with shortcuts? Could you do it?

dentuzhik commented 9 years ago

@SevInf are you interested in helpers for copy, cut and paste? I can implement them, but only with assumption that ctrl is used as modifier, unless there's a way to check a platform.

SevInf commented 9 years ago

@dentuzhik, yes, send PR.

There is a way to check a platform: browser.init is actually resolved with a capabilities, sent by WebDriver. Currently, the value is ignored but it has platform field which has standard set of values for major OSes.