3

I have an app that allows for a different behavior when a button is clicked while the option key is held down. I am trying to test the functionality with an acceptance tester, using $I->click() but I don't see any way to add modifiers like I can with pressKey.

Thanks!

DAB
  • 1,303
  • 14
  • 23

1 Answers1

0

Ok, I was able to figure out a workaround for this, based on this SO answer:

How to simulate a mouse click using JavaScript?

$I->waitForJS('var target = $("span")[0]; var event = target.ownerDocument.createEvent("MouseEvents"); event.initMouseEvent("click", true, true, target.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, true, false, false, 0, null); target.dispatchEvent(event); return true;', 3);

This will option click the first span element. I hard coded in all the values for simplification, but maybe someone wants to write a wrapper for the codeception project.

Community
  • 1
  • 1
DAB
  • 1,303
  • 14
  • 23