I need some help with SlimerJS. Basically my program needs to take input from stdin periodically to do the next task.
The following code works well with PhantomJS+CasperJS in case of reading from an external input, but fails to do the same in SlimerJS+CasperJS.
some code ...
var nextLink = system.stdin.readLine();
some code ...
Any thoughts about how to solve this problem ?
This simply isn't supported as evident by the feature request on GitHub and lack of
stdin
property in the documentation.There are mainly two workarounds possible. Both of the require that you write a second program in the language of your choice (can be a PhantomJS script).
When you come to the point in the CasperJS script where it is necessary to get input, you read a predefined file multiple times until something is inside it. So you execute the second program when you see that CasperJS is at this point. The program may be a simple command like
or something more elaborate. The polling functions in CasperJS would be something like this:
There is a webserver module that you can use to send messages to SlimerJS when it is running as a CasperJS script. The second program would need to send actual requests.