Skip to content

Commit d0e6d5d

Browse files
djdevinDevin Zuczek
andauthored
Add press button in row step. (#636)
Co-authored-by: Devin Zuczek <[email protected]>
1 parent b2de4f0 commit d0e6d5d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Drupal/DrupalExtension/Context/DrupalContext.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,25 @@ public function assertClickInTableRow($link, $rowText)
220220
throw new \Exception(sprintf('Found a row containing "%s", but no "%s" link on the page %s', $rowText, $link, $this->getSession()->getCurrentUrl()));
221221
}
222222

223+
/**
224+
* Attempts to find a button in a table row containing giving text. This is
225+
* for entity reference forms like Paragraphs, Inline entity form, etc.
226+
* where there may be multiple entities in a table, each with separate edit
227+
* buttons.
228+
*
229+
* @Given I press :button in the :rowText row
230+
*/
231+
public function assertPressInTableRow($button, $rowText)
232+
{
233+
$page = $this->getSession()->getPage();
234+
if ($button_element = $this->getTableRow($page, $rowText)->findButton($button)) {
235+
// Press the button and return.
236+
$button_element->press();
237+
return;
238+
}
239+
throw new \Exception(sprintf('Found a row containing "%s", but no "%s" button on the page %s', $rowText, $button, $this->getSession()->getCurrentUrl()));
240+
}
241+
223242
/**
224243
* @Given the cache has been cleared
225244
*/

0 commit comments

Comments
 (0)