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

Login Western-Union and save Headers after Login #35

Open
ziflar opened this issue Sep 15, 2017 · 1 comment
Open

Login Western-Union and save Headers after Login #35

ziflar opened this issue Sep 15, 2017 · 1 comment

Comments

@ziflar
Copy link

ziflar commented Sep 15, 2017

hello
thanks for this code it's helpful
i tried to run it and got a login to western-union and save headers on a output text file .but i have a problem to run it .

here my code

var x = require('casper').selectXPath;
casper.options.verbose = true;
casper.options.logLevel = 'debug';
casper.options.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4';
casper.options.viewportSize = {width: 1366, height: 648};
casper.on('page.error', function(msg, trace) {
   this.echo('Error: ' + msg, 'ERROR');
   for(var i=0; i<trace.length; i++) {
       var step = trace[i];
       this.echo('   ' + step.file + ' (line ' + step.line + ')', 'ERROR');
   }
});
casper.test.begin('Resurrectio test', function(test) {
   casper.start('https://www.westernunion.com/fr/fr/home.html');
   casper.waitForSelector(x("//a[normalize-space(text())='Se connecter']"),
       function success() {
           test.assertExists(x("//a[normalize-space(text())='Se connecter']"));
           this.click(x("//a[normalize-space(text())='Se connecter']"));
       },
       function fail() {
           test.assertExists(x("//a[normalize-space(text())='Se connecter']"));
   });
   casper.waitForSelector("form[name=registrnForm] input[name='txtEmailAddr']",
       function success() {
           test.assertExists("form[name=registrnForm] input[name='txtEmailAddr']");
           this.click("form[name=registrnForm] input[name='txtEmailAddr']");
       },
       function fail() {
           test.assertExists("form[name=registrnForm] input[name='txtEmailAddr']");
   });
   casper.waitForSelector("input[name='txtEmailAddr']",
       function success() {
           this.sendKeys("input[name='txtEmailAddr']", "[email protected]");
       },
       function fail() {
           test.assertExists("input[name='txtEmailAddr']");
   });
   casper.waitForSelector("form[name=registrnForm] input[name='txtKey']",
       function success() {
           test.assertExists("form[name=registrnForm] input[name='txtKey']");
           this.click("form[name=registrnForm] input[name='txtKey']");
       },
       function fail() {
           test.assertExists("form[name=registrnForm] input[name='txtKey']");
   });
   casper.waitForSelector("input[name='txtKey']",
       function success() {
           this.sendKeys("input[name='txtKey']", "tatattctaoc");
       },
       function fail() {
           test.assertExists("input[name='txtKey']");
   });
   casper.waitForSelector("form[name=registrnForm] button#btn-do-login",
       function success() {
           test.assertExists("form[name=registrnForm] button#btn-do-login");
           this.click("form[name=registrnForm] button#btn-do-login");
       },
       function fail() {
           test.assertExists("form[name=registrnForm] button#btn-do-login");
   });
   casper.then(function() {
    casper.waitWhileSelector(x("//*[@id='notification-message']"));
  });
//========  /* GET_SCREEN */ ==========
casper.then(function(){
    console.log("Make a screenshot and save it as AfterLogin.png");
casper.waitWhileSelector(x("//*[@id='notification-message']"));
    this.capture('AfterLogin.png');
});
//========  /* HEADERS */ ==========
casper.then(function dumpHeaders(){
  console.log("getting headers");
	this.currentResponse.headers.forEach(function(header){
    console.log(header.name +': '+ header.value);
  })
})
//========  /* submit form */ ==========

   casper.run(function() {test.done();});
});

any help ?

@telemehanik12
Copy link

telemehanik12 commented Oct 7, 2021

Good afternoon. I tried this code and it didn't work for me either. I tried to run it and got the western-union login and saved the headers in the output text file. I also wanted to try it on a similar site western union locations, but I have a problem launching it. I do not understand at what stage the project is.

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

No branches or pull requests

2 participants