Note that there are some explanatory texts on larger screens.

plurals
  1. POBehat/Mink is it possible to do a find through an incomplete string?
    primarykey
    data
    text
    <p>I've been working in BDD through Behat|Mink.</p> <p>However I'm failing in finding an input (field) with an ID or Name if they aren't complete.</p> <p>I intended to do something like:</p> <pre><code> $field = $this-&gt;getSession()-&gt;getPage()-&gt;findField( "*first_name*" ); </code></pre> <p>where the <strong>'*'</strong> meant that can be any piece of string there.</p> <p>The problem is that i have a case where I can't know for sure the complete ID cause:</p> <pre><code> id="&lt;random-string&gt;_&lt;actual-field-name&gt;_&lt;random-number&gt;" </code></pre> <p>Any idea how can I do this?</p> <p>What have I tried</p> <pre><code>- 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) </code></pre> <p>Edit:</p> <p>I've created a php function to read the attribute and return the value of the intended attribute.</p> <pre><code>/** * * @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' ) </code></pre> <p>However, in cases that there is another fields (ex: hidden login form) and the needle is also in those inputs, it will get them if they're first.</p> <p>So I need to specify the form, however, once more, there I haven't a way to find a form through name:</p> <pre><code> $field = $this-&gt;getSession()-&gt;getPage()-&gt;find( 'named', array( 'form', $formName ) ); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload