Skip to content

Commit

Permalink
#589: Click fieldset summary to reveal
Browse files Browse the repository at this point in the history
  • Loading branch information
xurizaemon committed Jul 5, 2021
1 parent 40af5f3 commit ac7d592
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Drupal/DrupalExtension/Context/MinkContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,27 @@ public function assertSelectRadioById($label, $id = '')
$radiobutton->selectOption($value, false);
}

/**
* Expand a <details> element by <summary>.
*
* @Given I expand details labelled :summary
*/
public function iExpandDetailsByLabel($summary)
{
$page = $this->getSession()->getPage();
$element = $page->find('xpath', "//details/summary[@aria-expanded='false']/*[text()='Related content']");
if (empty($element)) {
throw new \Exception("Unable to find details element containing text $summary");
}
try {
$element->click();
usleep(100000);
} catch (UnsupportedDriverActionException $exception) {
// Goutte etc only supports clicking link, submit, button;
// for non-JS drivers this won't impact test.
}
}

/**
* @} End of defgroup "mink extensions"
*/
Expand Down

0 comments on commit ac7d592

Please sign in to comment.