mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #7221 from open-sausages/pulls/4.0/select-the-black-behat
Fix add function for selecting a value in the new tree dropdown
This commit is contained in:
commit
1cf644c00a
@ -7,6 +7,7 @@ use Behat\Behat\Context\Context;
|
||||
use Behat\Mink\Exception\ElementHtmlException;
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
use SilverStripe\BehatExtension\Context\MainContextAwareTrait;
|
||||
use SilverStripe\BehatExtension\Utility\StepHelper;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
use Behat\Mink\Element\NodeElement;
|
||||
use SilverStripe\SiteConfig\SiteConfig;
|
||||
@ -19,6 +20,7 @@ use SilverStripe\SiteConfig\SiteConfig;
|
||||
class CmsFormsContext implements Context
|
||||
{
|
||||
use MainContextAwareTrait;
|
||||
use StepHelper;
|
||||
|
||||
/**
|
||||
* Get Mink session from MinkContext
|
||||
@ -255,6 +257,36 @@ JS;
|
||||
$siteConfig->flushCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a value in the tree dropdown field
|
||||
*
|
||||
* NOTE: This is react specific, may need to move to its own react section later
|
||||
*
|
||||
* @When /^I select "([^"]*)" in the "([^"]*)" tree dropdown$/
|
||||
*/
|
||||
public function iSelectValueInTreeDropdown($text, $selector)
|
||||
{
|
||||
$page = $this->getSession()->getPage();
|
||||
$parentElement = null;
|
||||
$this->retryThrowable(function () use (&$parentElement, &$page, $selector) {
|
||||
$parentElement = $page->find('css', $selector);
|
||||
assertNotNull($parentElement, sprintf('"%s" element not found', $selector));
|
||||
$page = $this->getSession()->getPage();
|
||||
});
|
||||
|
||||
$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) {
|
||||
$element = $parentElement->find('xpath', sprintf('//*[count(*)=0 and contains(.,"%s")]', $text));
|
||||
assertNotNull($element, sprintf('"%s" not found in "%s"', $text, $selector));
|
||||
$element->click();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate an HTML editor field
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user