diff --git a/src/lib/Behat/Component/Fields/Country.php b/src/lib/Behat/Component/Fields/Country.php index 0877d3cdc2..f46a36357d 100644 --- a/src/lib/Behat/Component/Fields/Country.php +++ b/src/lib/Behat/Component/Fields/Country.php @@ -8,18 +8,25 @@ namespace Ibexa\AdminUi\Behat\Component\Fields; -use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion; +use Behat\Mink\Session; +use Ibexa\AdminUi\Behat\Component\IbexaDropdown; use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; -use PHPUnit\Framework\Assert; class Country extends FieldTypeComponent { + private IbexaDropdown $dropdown; + + public function __construct(Session $session, IbexaDropdown $dropdown) + { + parent::__construct($session); + $this->dropdown = $dropdown; + } + public function setValue(array $parameters): void { $this->getHTMLPage()->find($this->getLocator('dropdownSelector'))->click(); - Assert::assertTrue($this->getHTMLPage()->find($this->getLocator('dropdownExpanded'))->isVisible()); - $this->getHTMLPage()->findAll($this->getLocator('dropdownItem'))->getByCriterion(new ElementTextCriterion($parameters['value']))->click(); - $this->getHTMLPage()->find($this->getLocator('dropdownSelector'))->click(); + $this->dropdown->verifyIsLoaded(); + $this->dropdown->selectOption($parameters['value']); } public function getFieldTypeIdentifier(): string @@ -32,8 +39,6 @@ public function specifyLocators(): array return [ new VisibleCSSLocator('fieldInput', 'select'), new VisibleCSSLocator('dropdownSelector', '.ibexa-dropdown__selection-info'), - new VisibleCSSLocator('dropdownExpanded', '.ibexa-dropdown-popover .ibexa-dropdown__items'), - new VisibleCSSLocator('dropdownItem', '.ibexa-dropdown__item'), ]; } }