gemini-testing / gemini

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

Custom suite commands #197

Open DimitryDushkin opened 9 years ago

DimitryDushkin commented 9 years ago

It will be nice to have ability to add custom suite commands like in webdriver.io — http://webdriver.io/guide/usage/customcommands.html

For example, it will be helpful to have such command:

suite
  .setUrl('yandex.ru')
  .waitForJSInit()
  .setCaptureElements(...)
  ...
fenduru commented 9 years ago

:+1: this would be very useful

fenduru commented 8 years ago

@SwinX I'm interested in contributing support for this. Do you have any idea of the kind of API you'd want for this?

My use case is that my application has multiple themes, and I want to write one .capture() and have it run multiple times based on the theme. Ideally I would be able to decorate .capture() to do this, or I could add a custom command like captureThemes().

SwinX commented 8 years ago

@fenduru thank you for your intent! This may be a really nice feature. I may propose following way to do this:

As you may know gemini has plugins support. Gemini instance is being passed to plugin. You may want to add there some method like addCommand(name, action), where action will be smth like function() {...};. So we have entry point where command may be added. Now we need to pass command to suites. This may be done by collecting new commands in some hash at tests-api.js:

var commands = {};

Then in SuiteBuilder constructor we need to add something like:

var self = this;
_.(commands).each(function(action, name) {
    self[name] = action.bind(self);
});

Seems this is all we need to modify to get custom commands feature. In this implementation you will be able to access all available SuiteBuilder API and other custom commands using this keyword. If you see a better way please let me know, will be happy to discuss it.

/cc @j0tunn @sipayRT

fenduru commented 8 years ago

@SwinX :+1: I'll try something like that out. Thanks for the guidance