0

I have the following HTML code snippet:

<div class="modal-body" style="max-height: 317px;">
   <div class="radio">
      <label>
         <input type="radio" name="template" value="5">
         <img src="/img/custom-icons/Monitor.png" style="height: 24px">
         First descriptive title                    
         <p class="text-muted">Some description text</p>
      </label>
   </div>
   <div class="radio">
      <label>
         <input type="radio" name="template" value="37">
         <img src="/img/custom-icons/Monitor.png" style="height: 24px">
         Second descriptive title                   
         <p class="text-muted"></p>
      </label>
   </div>
   <div class="radio">
      <label>
         <input type="radio" name="template" value="46">
         <img src="/img/custom-icons/Chart_Area_Up.png" style="height: 24px">
         Third descriptive title                    
         <p class="text-muted">Some text that describes an item.</p>
      </label>
   </div>
</div>

I want to select radio element by its label text and click it. What I'm trying to do:

$this->byXPath( "//label[text()='Second descriptive title']" )->click();

Unfortunately that is not working. Any ideas? I would be appreciated for your help.

1 Answer 1

2
//div[@class='radio']//*[contains(.,'Second descriptive title ')]//input[@type='radio']

Pretty tricky. There could be a better way. But, this is what I can suggest. Doing a tag independent search on self with //*[contains(.,'Second descriptive title')] and after that just walking to the input radio tag

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.