I found a child by text in the following way.
Driver.FindElement(By.XPath("//span[contains(@class,'MyClass')][contains(text(),'MyText')]"));
The problem is that I need to click on the parent element. The element on the page appears dynamically and for earlier I only know the text. Is it possible to program this?
My html:
<div class="list-item list-item-station ui-draggable ui-draggable-handle">
<div class="operations">
<span class="fa fa-times"></span>
</div>
<div class="icon-image image-item">
<span class="fa fa-user"></span>
</div>
<div class="icon-name editable-input-long">
<span class="will-edit will-edit-input will-edit-textarea">MyText</span><textarea class="editable- textarea"></textarea>
</div>
</div>