0

I'm trying to test whether navigating with the tab key works on my system. Here is my code:

define('TAB_CHARCODE', 9);
define('NO_MODIFIER', '');
// ....
$this->getSession()->getPage()->find('css', ':focus')->keyPress(TAB_CHARCODE, NO_MODIFIER);

This yields: "The pseudo-class focus is unsupported" How does one obtain, in Behat, the currently focused element? Cheers,

Albert

alberto56
  • 2,997
  • 3
  • 28
  • 47

1 Answers1

1

Yeah mink does not support all pseudo classes. As as walk around you can use executeScript method which execute js script at your page. So if you use jQuery you can do something like this:

$this->mink->getSession()->executeScript("
    $(':focus').trigger($.Event('keypress', {which: 9, keyCode: 9}));
");
l3l0
  • 3,363
  • 20
  • 19
  • Thanks for the response. I can see that an element has focus on the screen because I just selected it, yet this tells me that $(:focus) is null. – alberto56 Jan 08 '13 at 16:59