0

Iam new with Javascript(since yesterday) and i really dont know, why my script does not work. I try do login to this Website, with multiple Data out of a .txt file. They are in File like: id:pw(/n)id:pw(/n)... and so on

function login(MYID,MYPW){

            var x = require('casper').selectXPath;
            var url = 'http://leya2.eu/';

            var casper = require('casper').create({
                verbose: false,
                logLevel: 'debug'
            });
            phantom.casperTest = true;
            casper.test.comment('Start');

            casper.start(url, function() {  
            this.waitForSelector("leya2.jpg",
                function pass () {
                },
                function fail () {
                },
                20000
            );

            casper.then(function() {
            this.sendKeys('input[name=userid]', 'Dantes999');
            this.sendKeys('input[name=userpass]', '123456789');
            this.click('input[value="LOGIN"]')
            });

            casper.then(function() {    
                this.fill('form[class="login"]', {
                  'userid': 'Dantes999',
                  'userpass': '123456789'
                }, true);
            });

            casper.then(function() {
                //console.log(this.getPageContent());
            });

            });

            casper.run(function() {
                this.echo('done');
            return 
                this.exit();
            });
}



var fs = require('fs');
var stream = fs.open('acc_all.txt', 'r');

while(!stream.atEnd()) {
    var line = stream.readLine();
    console.log(line);
var id = str.substring(0,":");   
var pw = str.substring(":",end);  

var a = login(function() {id},{pw});
}
stream.close();

Error message is like missing }

2
  • where are you calling "login()"? aren't you just assign a variable with "var a = login(function() {id},{pw});"`?
    – Ben jamin
    Jul 21, 2017 at 10:46
  • so a should return some data ? something like, login sucessfull or not... hmm i think best way is.. 1. load website 2. get login data 3. login 4. success ?(seach for field "logout") else fail 5. notice if fail or not but idk why at the moment it does not work =/ Compiler: SyntaxError: Unexpected token '}'
    – V0lvox337
    Jul 21, 2017 at 12:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.