From 33c2fde1ae9a18b37a43ddea07d321ba4bc802f9 Mon Sep 17 00:00:00 2001 From: Chris Burgess Date: Mon, 5 Jul 2021 20:23:43 +1200 Subject: [PATCH] jhedstrom/drupalextension#589: Click fieldset summary to reveal --- .../DrupalExtension/Context/MinkContext.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Drupal/DrupalExtension/Context/MinkContext.php b/src/Drupal/DrupalExtension/Context/MinkContext.php index e2ac026f..0db52e65 100644 --- a/src/Drupal/DrupalExtension/Context/MinkContext.php +++ b/src/Drupal/DrupalExtension/Context/MinkContext.php @@ -611,6 +611,27 @@ public function assertSelectRadioById($label, $id = '') $radiobutton->selectOption($value, false); } + /** + * Expand a
element by . + * + * @Given I expand details labelled :summary + */ + public function iExpandDetails($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" */