Skip to content

Commit

Permalink
MNT Behat test for gridfield object on page
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabina Talipova committed Jan 7, 2024
1 parent d946d69 commit 1013961
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Context/BasicContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,32 @@ public function iClickInTheElement($clickType, $text, $selector)
$element->$clickTypeFn();
}

/**
* @Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element on page$/
* @param string $clickType
* @param string $text
* @param string $selector
*/
public function iClickInTheElementOnPage($clickType, $text, $selector)
{
$clickTypeMap = array(
"double click" => "doubleclick",
"click" => "click"
);
$page = $this->getSession()->getPage();
//$parentElement = $page->find('css', $selector);
$parentElement = $page->findAll('css', $selector);
$i = 0;
foreach ($parentElement as $pelement) {
$i++;
Assert::assertNotNull($parentElement, sprintf('"%s" element not found', $selector));
$element = $pelement->find('xpath', sprintf('//*[count(*)=' . $i . ' and contains(.,"%s")]', $text));
Assert::assertNotNull($element, sprintf('"%s" not found', $text));
$clickTypeFn = $clickTypeMap[$clickType];
$element->$clickTypeFn();
}
}

/**
* Needs to be in single command to avoid "unexpected alert open" errors in Selenium.
* Example: I click "Delete" in the ".actions" element, confirming the dialog
Expand Down

0 comments on commit 1013961

Please sign in to comment.