0

I have been on this for the past two days and tried different methods of clicking. I need to wait for the page to load and then simulate a click. I use:

 waitForKeyElements (".button.bbutton.unbind_later", clickOnFollowButton);  
function clickOnFollowButton (jNode) {
    var clickEvent  = document.createEvent ('MouseEvents');
    clickEvent.initEvent ('click', true, true);
    jNode[0].dispatchEvent (clickEvent);
}

The simulated click returns what I believe is a JSON array displayed in a blank new page. Example:

{"t_ref":"KL26208","price":"1.77","display":"<div class=\"confirm_wrapper\">\n    <h4>Tconfirmation</h4>....."}

But when I click manually, I stay on the same page. Part of the page displays a confirmation /thank you message (the page is not reloaded and no new (blank) page when I click manually).

Do I have to parse some data to the click event? How can I simulate the manual click?

The event handler

// =====chrome inspect elements snippet ======
handler: function (e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)}
arguments: null
caller: null
elem: button.bbutton.unbind_later
length: 1
name: ""
prototype: Object
constructor: function (e){return typeof b===i||e&&b.event.triggered===e.type?t:b.event.dispatch.apply(f.elem,arguments)}
__proto__: Object
__proto__: function Empty() {}
Tim Seguine
  • 2,887
  • 25
  • 38

1 Answers1

0

Have you tried initMouseEvent?

KOLANICH
  • 2,904
  • 2
  • 20
  • 20
  • I used the initMouseEvent example from the answer in --> [link](http://stackoverflow.com/questions/5658849/whats-the-equivalent-of-jquerys-trigger-method-without-jquery) The result is the same. json array returned in a white page after the click event occurs – user3113019 Dec 17 '13 at 23:58
  • Also tried the answer in [link](http://stackoverflow.com/questions/6157929/how-to-simulate-mouse-click-using-javascript) ... gives same result – user3113019 Dec 18 '13 at 13:05