mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Fix add function for selecting a value in the new tree dropdown in behat using react
This commit is contained in:
parent
697798b464
commit
4e222fc189
@ -7,6 +7,7 @@ use Behat\Behat\Context\Context;
|
|||||||
use Behat\Mink\Exception\ElementHtmlException;
|
use Behat\Mink\Exception\ElementHtmlException;
|
||||||
use Behat\Gherkin\Node\TableNode;
|
use Behat\Gherkin\Node\TableNode;
|
||||||
use SilverStripe\BehatExtension\Context\MainContextAwareTrait;
|
use SilverStripe\BehatExtension\Context\MainContextAwareTrait;
|
||||||
|
use SilverStripe\BehatExtension\Utility\StepHelper;
|
||||||
use Symfony\Component\DomCrawler\Crawler;
|
use Symfony\Component\DomCrawler\Crawler;
|
||||||
use Behat\Mink\Element\NodeElement;
|
use Behat\Mink\Element\NodeElement;
|
||||||
use SilverStripe\SiteConfig\SiteConfig;
|
use SilverStripe\SiteConfig\SiteConfig;
|
||||||
@ -19,6 +20,7 @@ use SilverStripe\SiteConfig\SiteConfig;
|
|||||||
class CmsFormsContext implements Context
|
class CmsFormsContext implements Context
|
||||||
{
|
{
|
||||||
use MainContextAwareTrait;
|
use MainContextAwareTrait;
|
||||||
|
use StepHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Mink session from MinkContext
|
* Get Mink session from MinkContext
|
||||||
@ -255,6 +257,31 @@ JS;
|
|||||||
$siteConfig->flushCache();
|
$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 = $page->find('css', $selector);
|
||||||
|
assertNotNull($parentElement, sprintf('"%s" element not found', $selector));
|
||||||
|
|
||||||
|
$dropdown = $parentElement->find('css', '.Select');
|
||||||
|
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
|
* Locate an HTML editor field
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user