Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a REPL for taiko #2

Closed
zabil opened this issue Oct 30, 2017 · 6 comments
Closed

Provide a REPL for taiko #2

zabil opened this issue Oct 30, 2017 · 6 comments

Comments

@zabil
Copy link
Member

zabil commented Oct 30, 2017

Package taiko as a command line tool and library.

Modify taiko.js

  • Add shebang
#! /usr/bin/env node
  • Link it to /usr/bin/taiko after npm -g install taiko

Initialize the REPL using

$ taiko

Implement custom commands for taiko api

#! /usr/bin/env node

const repl = require('repl');

// Just an example. Implement it inside taiko.js
const _ = require('./taiko')

const server = repl.start({
    prompt: '>> '
});

server.defineCommand('openBrowser', {
    help: 'Opens a browser',
    async action() {
        await _.openBrowser({
            headless: false
        });
        this.displayPrompt();
    }
});

server.defineCommand('goto', {
    help: 'Goto a URL',
    async action(url) {
        await _.goto(url);
        this.displayPrompt();
    }
});

server.defineCommand('click', {
    help: 'Goto a URL',
    async action(item) {
        await _.click(item);
        this.displayPrompt();
    }
});

Can be run as

$ taiko
>> .openBrowser
>> .goto http://getgauge.io
>> .click Get Started
@kashishm
Copy link
Contributor

kashishm commented Nov 1, 2017

action The function to execute, optionally accepting a single string argument.

The command callback action can only take one string parameter (documentation). I am not sure how the following would be possible

click(button('Alert'));
click($('id'));
write('Hooks', into(field));

@zabil
Copy link
Member Author

zabil commented Nov 3, 2017

This is now changed to a REPL that understands await e.g

>> openBrowser()
>> goto("http://getgauge.io")
>> click("Get Started")

@zabil zabil added in progress and removed ready labels Nov 7, 2017
@kashishm
Copy link
Contributor

kashishm commented Nov 8, 2017

Implemented.

@sswaroopgupta
Copy link
Contributor

sswaroopgupta commented Nov 15, 2017

Test cases

  • I should be able to initialize REPL using taiko command
  • Should be able to initialize it from a project using taiko

On windows global installation of taiko is successful.
I am able to initialize taiko from a project
However REPL is not getting initialized using the taiko command outside the project directory.

@sswaroopgupta
Copy link
Contributor

sswaroopgupta commented Nov 15, 2017

After REPL is initialized, I have to explicitly close the browser. Only then the command prompt is getting initialized.

Furthermore, .exit does not closeBrowser automatically.

Note I am working on Windows OS

@kashishm
Copy link
Contributor

@sguptatw With the latest, it won't open the browser on running taiko command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants