2015-02-23 75 views
0

硒PHPUnit的選擇元素,我有以下的HTML代碼片段:通過標籤文本

<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> 

我想通過它的標籤文本選擇電臺元素並單擊它。我在做什麼:

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

不幸的是,這是行不通的。有任何想法嗎?我將不勝感激您的幫助。

回答

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

非常棘手。可能有更好的方法。但是,這是我可以建議的。做一個tag獨立搜索self//*[contains(.,'Second descriptive title')]和之後,只是步行到input電臺tag