Skip to content

Reading and accepting input from user during execution #639

@kensoh

Description

@kensoh

versions

  • SlimerJS: v0.10.3
  • Firefox: v54.0.1 (64-bit)
  • Operating system: macOS (10.12.6 (16G29))

Steps to reproduce the issue

Run a bare-minimum script to read input using sys.stdin.read() from SlimerJS doc

var casper = require('casper').create();
casper.start('http://casperjs.org/');

casper.then(function() {
    this.echo(this.getTitle());
    var input = ''; var sys = require('system');
    sys.stdout.write('ENTER INPUT: ');
    input = sys.stdin.read();
    this.echo(input);
});

casper.run();

Actual results:

Entered something but nothing happens, if nothing is entered script also exits

Expected results:

The input is read correctly and able to be used later on (echo, used as selector etc)

Additional details:

Posted this 2 months ago to a related SlimerJS issue. But it is a closed issue, so I thought to repost here as a new issue. #188 I'm not sure if other users are facing this and not sure if I used the method in the wrong way that's why it's not working. When run with PhantomJS it is ok using sys.stdin.readLine().

UPDATE - forgot to paste the error message received (same as the error I posted in issue 188). This error happens whether I enter something or do nothing and wait for a few seconds for it to appear.

JavaScript error: resource://slimerjs/addon-sdk/toolkit/loader.js -> resource://slimerjs/addon-sdk/sdk/io/byte-streams.js, line 73: Error: Error reading from stream: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIBinaryInputStream.readBytes]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: resource://slimerjs/addon-sdk/toolkit/loader.js -> resource://slimerjs/addon-sdk/sdk/io/byte-streams.js :: ByteReader_read :: line 68"  data: no]
2017-08-05T18:46:51.182Z [DEBUG] webpage: close

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions