Select2를 사용하여 웹 UI로 Behat 시나리오를 만들려고합니다.Behat/Mink 및 Select2 콤보
Select 값을 변경하려고하면 Select2로 숨기는 기본 선택 때문에 Behat 오류가 발생했습니다.
그러나 밉크와 상호 작용할 수 없기 때문에 이미 select2 구성 요소에 오류가 있습니다.
이미 Select2에 Behat/Mink를 사용하셨습니까? 나 좀 도와 주겠니?
Select2를 사용하여 웹 UI로 Behat 시나리오를 만들려고합니다.Behat/Mink 및 Select2 콤보
Select 값을 변경하려고하면 Select2로 숨기는 기본 선택 때문에 Behat 오류가 발생했습니다.
그러나 밉크와 상호 작용할 수 없기 때문에 이미 select2 구성 요소에 오류가 있습니다.
이미 Select2에 Behat/Mink를 사용하셨습니까? 나 좀 도와 주겠니?
. 여기
가장 완벽한 단계의 추출물 : 나는 Github에서의 며칠 소스 선택 2 컨텍스트를 열고거야
/**
* @When /^(?:|I)fill in select2 input "(?P<field>(?:[^"]|\\")*)" with "(?P<value>(?:[^"]|\\")*)" and select "(?P<entry>(?:[^"]|\\")*)"$/
*/
public function iFillInSelectInputWithAndSelect($field, $value, $entry)
{
$page = $this->getSession()->getPage();
$inputField = $page->find('css', $field);
if (!$inputField) {
throw new \Exception('No field found');
}
$choice = $inputField->getParent()->find('css', '.select2-selection');
if (!$choice) {
throw new \Exception('No select2 choice found');
}
$choice->press();
$select2Input = $page->find('css', '.select2-search__field');
if (!$select2Input) {
throw new \Exception('No input found');
}
$select2Input->setValue($value);
$this->getSession()->wait(1000);
$chosenResults = $page->findAll('css', '.select2-results li');
foreach ($chosenResults as $result) {
if ($result->getText() == $entry) {
$result->click();
break;
}
}
}
.
[Github] (https://github.com/novaway/BehatCommonContext)에서 select2 컨텍스트 소스를 엽니 다. 브랜치 1.x는 Behat2와 호환되며 2.x는 Behat3과 호환됩니다. –
나는 그 중 하나와 붙어 있었지만, 내가 찾은 정보를 가지고 갔다. Filling in hidden inputs with Behat.
/**
* @Given /^I fill hidden field "([^"]*)" with "([^"]*)"$/
*/
public function iFillHiddenFieldWith($class, $value){
$this->getSession()->getPage()->find('css', $class)->setValue($value);
}
그리고 나는 다음과 같은 방법을 사용합니다 :
내 솔루션은 약간 차이가 나는 마지막으로 사용자가 할 수있는 것처럼 선택 2 필드와 상호 작용 Behat 쓰기
And I fill hidden field "#s2id_edit-my-field input" with "random value".
코드를 알려주십시오. –