저는 Bhat에서 Behat | Mink를 통해 일해 왔습니다.Behat/Mink는 불완전한 문자열을 통해 찾기를 수행 할 수 있습니까?
그러나 입력이 완료되지 않은 경우 ID 또는 이름이있는 입력 (필드)을 찾지 못했습니다.
내가 좋아하는 뭔가를 할 의도 :$field = $this->getSession()->getPage()->findField("*first_name*");
곳 '*'가이 문자열의 조각이 될 수 의미했다. 나는이 작업을 수행 할 수있는 방법
id="<random-string>_<actual-field-name>_<random-number>"
어떤 생각 :
문제
내가 확실 전체 ID 원인을 알 수없는 경우가 있다는 것입니다? 무엇을 가지고나는
- get it through label (for some reasons there are some labels that dont have 'for' attribute and sometimes the name is a sentence and not an simple name)
- get it through css/classes (to many variables)
을 시도 편집 : 나는 의도 된 속성의 값을 속성을 읽고 반환하는 PHP 함수를 만들었습니다
.
/**
*
* @param string $haystack The complete html
* @param string $needle The string with the part of the attribute value
* @param string $tag The tag of where the attribute should belong
* @param string $attr The attribute to ifnd
* @return string
*/
protected function findCompleteAttribute($haystack, $needle, $tag = null, $attr = 'id')
그러나, 경우에 또 다른 필드가 있다고 (예 : 숨겨진 로그인 폼)와 바늘은 처음 인 경우 그 입력에, 그들을 얻을 것이다이기도합니다.
그래서 내가 거기 내가 이름을 통해 양식을 찾을 수있는 방법을하지 않은, 그러나, 한 번 더, 양식을 지정해야합니다
$field = $this->getSession()->getPage()->find('named', array('form', $formName));
@ 그레트 롤 레즈 – mloureiro