Sulu\Bundle\AdminBundle\Behat\AdminContext::iSelectFromTheHuskyAutoComplete PHP Метод

iSelectFromTheHuskyAutoComplete() публичный Метод

Select a value from husky select list.
public iSelectFromTheHuskyAutoComplete ( string $itemValue, string $selector )
$itemValue string
$selector string Container element of the field
    public function iSelectFromTheHuskyAutoComplete($itemValue, $selector)
    {
        $containerElement = $this->getSession()->getPage()->find('css', $selector);
        if (null === $containerElement) {
            throw new ElementNotFoundException($this->getSession(), $selector);
        }
        $inputElement = $containerElement->find('css', 'input.tt-input');
        if (null === $inputElement) {
            throw new ElementNotFoundException($this->getSession(), $inputElement);
        }
        // Workaround for $element->setValue() because this function adds a TAB key at the end.
        // See https://github.com/minkphp/MinkSelenium2Driver/issues/188 for more information.
        $el = $this->getSession()->getDriver()->getWebDriverSession()->element('xpath', $inputElement->getXpath());
        $el->postValue(['value' => [$itemValue]]);
        // Wait until loading is finished.
        $this->spin(function (RawMinkContext $context) use($containerElement) {
            // Search for all displayed suggestions.
            $suggestionElementSelector = '.tt-suggestions .suggestion';
            $suggestionElements = $containerElement->findAll('css', $suggestionElementSelector);
            if (null === $suggestionElements) {
                throw new ElementNotFoundException($this->getSession(), $suggestionElementSelector);
            }
            // Choose the first item in the list.
            $suggestionElements[0]->click();
            $loaderElementSelector = '.loader';
            $loaderElement = $containerElement->find('css', $loaderElementSelector);
            if ($loaderElement && $loaderElement->isVisible()) {
                return false;
            }
            return true;
        });
    }