What normal JavaScript functions are available in

2019-09-08 01:57发布

My question is best illustrated by example.

I'm attempting to begin writing some regression tests in CasperJS. However, the website requires authentication (not Basic HTTP Auth), so I'll be using the setup option function to log in for the duration of the tests. However, I don't want to hardcode this into the script for obvious reasons. My solution is to read in the credentials from stdin using system. However, I am trying to use readLine since I don't know the length ahead of time. This captures a newline at the end. I don't want the newline so I'm trying to trim it off the end. However, calling username.slice(0,-1) results in a crash, I think.

It doesn't actually display any error, it just hangs.

Thus, my question is what IS available in PhantomJS that we would be used to having in a normal JS environment? Is there a list somewhere?

Bonus points if you know a way to configure CasperJS in the scenario of a login.

EDIT: Test code, as requested. On my machine, it does nothing after you submit the username.

var system = require('system')
system.stdout.write("Please input username: ")
username = system.stdin.readLine()
user = username.slice(0,-1) // or trim()
system.stdout.write("You entered: " + user);

0条回答
登录 后发表回答