Fix behat tree dropdown trigger

This commit is contained in:
Damian Mooyman 2017-07-28 13:34:49 +12:00
parent 4e222fc189
commit a85bc86fd3
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A

View File

@ -256,7 +256,7 @@ JS;
$siteConfig->write(); $siteConfig->write();
$siteConfig->flushCache(); $siteConfig->flushCache();
} }
/** /**
* Select a value in the tree dropdown field * Select a value in the tree dropdown field
* *
@ -267,21 +267,26 @@ JS;
public function iSelectValueInTreeDropdown($text, $selector) public function iSelectValueInTreeDropdown($text, $selector)
{ {
$page = $this->getSession()->getPage(); $page = $this->getSession()->getPage();
$parentElement = $page->find('css', $selector); $parentElement = null;
assertNotNull($parentElement, sprintf('"%s" element not found', $selector)); $this->retryThrowable(function () use (&$parentElement, &$page, $selector) {
$parentElement = $page->find('css', $selector);
$dropdown = $parentElement->find('css', '.Select'); assertNotNull($parentElement, sprintf('"%s" element not found', $selector));
assertNotNull($dropdown, sprintf('Unable to find the dropdown in "%s"', $selector)); $page = $this->getSession()->getPage();
$dropdown->click(); });
$this->retryThrowable(function () use ($parentElement, $selector) {
$dropdown = $parentElement->find('css', '.Select-arrow');
assertNotNull($dropdown, sprintf('Unable to find the dropdown in "%s"', $selector));
$dropdown->click();
});
$this->retryThrowable(function () use ($text, $parentElement, $selector) { $this->retryThrowable(function () use ($text, $parentElement, $selector) {
$element = $parentElement->find('xpath', sprintf('//*[count(*)=0 and contains(.,"%s")]', $text)); $element = $parentElement->find('xpath', sprintf('//*[count(*)=0 and contains(.,"%s")]', $text));
assertNotNull($element, sprintf('"%s" not found in "%s"', $text, $selector)); assertNotNull($element, sprintf('"%s" not found in "%s"', $text, $selector));
$element->click(); $element->click();
}); });
} }
/** /**
* Locate an HTML editor field * Locate an HTML editor field
* *