0

I have a page with two frames:

<frameset>
<frame src="left.php" name="left">
<frame src="right.php" name="right">
<span id="aButton"><a href="gosomewhere.php"><span class="buttonContainer"><span class="buttonText">a button</span></span></a></span>
</frameset>

I want to click the link inside the second frame like this:

page.render("screen1.jpg");
page.switchToFrame("right");
var recta = page.evaluate(function() {
  return document.querySelector('#aButton a').getBoundingClientRect();
});

page.sendEvent('click', recta.left + recta.width / 2, recta.top + recta.height / 2);
page.render("screen2.jpg");
console.log(page.frameContent);

However, the click does not seem to register as my screen2.jpg shows no change. frameContent only shows html from frame "right", so I know that switchToFrame is working.

Is there a special way to handle clicking inside frames beyond the switchToFrame function? I have also tried document.querySelector('#aButton a').click() but no luck.

Josip Ivic
  • 3,639
  • 9
  • 39
  • 57
zoltar
  • 706
  • 2
  • 7
  • 20
  • Does the click trigger some kind of request? If so, then you need to wait for it's response. – Artjom B. Nov 15 '15 at 18:39
  • It just loads a new page inside the frame. I'm using a typical waitFor, but that isn't the problem. Even inside the waitFor I have screenshots that all look the same as screen1.jpg, so it seems clear the link isn't getting clicked. – zoltar Nov 15 '15 at 18:59
  • Which PhantomJS version do you use? Please register to the `onConsoleMessage`, `onError`, `onResourceError`, `onResourceTimeout` events ([Example](https://gist.github.com/artjomb/4cf43d16ce50d8674fdf#file-1_phantomerrors-js)). Maybe there are errors. Have you tried other solutions from here: http://stackoverflow.com/q/15739263/1816580 – Artjom B. Nov 15 '15 at 19:02

0 Answers0