Im a newbie to phantomjs/casperjs. Im trying to click an href that has a javascript function (href='javascript:getPhoneNumber(....)) and I want to get the printed result which an a png image. here is the html block before the click:
<div class="logo_text_link">
<img class="logo_text_link" src="//static.awebsite.com/img/devices/mobile/awebsite_mobile_view_phone.png" alt="Telephoner">
<span id="phoneNumber"><a class="nohistory adview_links" href='javascript:getPhoneNumber("https://api.awebsite.com", 1117004764, "54bb0281238b45a03f0ee695f73e704f")'>See the number </a></span
</div>
and here's the html block after the click:
<div class="logo_text_link">
<img class="logo_text_link" src="//static.awebsite.com/img/devices/mobile/awebsite_mobile_view_phone.png" alt="Telephoner">
<span id="phoneNumber"><div class="phoneimg"></div><img class="AdPhonenum" src="https://www.awebsite.com/pg/0f/AxLHLu0zHVAtWTp+nJCc2KkcZTdPfX3CM=.gif"></span>
</div>
I'am aiming at getting the img link (href) using casperjs. Im new to using it so I haven't tried much actually :S
var casper = require('casper').create();
casper.start("http://mobile.awebsite.com/ventes_immobilieres/1117004764.htm?ca=12_s");
var a="dd";
casper.echo('before then');
casper.then(function() {
b=casper.click(x('//*[@id="phoneNumber"]/a'));
casper.evaluate(function() {
a = getPhoneNumber("https://api.awebsite.com", 1117004764, "54bb0281238b45a03f0ee695f73e704f") ;
});
casper.echo(a);
casper.echo(b);
});
casper.run();
If anyone know how to get this task done I'd be really grateful (I've been struggling for 2 days now) !