Search code examples
phpseleniumtestingbehatmink

manipulating a tag label with mink


I would like to click on label corresponding to checkbox using mink php code. The code look like this:

<label class="label" for="somecheckbox_Id"> heylabel
 </label>

I can parse the checkbox for manipulation, can't parse the label. To parse the checkbox I did it like this

$doc= $this->getSession()->getPage()->find('css','#somecheckbox_Id'); 

how can I access the corresponding label?


Solution

  • Labels should always have a "for" attribute pointing to the checkbox in question. So, simply use

    $page->find('css', 'label[for='+name+']');