Reputation: 75
I try to click on <button>
element that is child of <div>
. The <div>
also contains <span>
element with certain text that I stored some steps before. I have lots of elements that have the structure below, but only one of them contains the exact text in the <span>
. Based on the text in this <span>
I want to click on the <button>
above.
The structure of the HTML:
<td>
<div>
<button> Click </button>
<span> From ORI-1730 </span>
</div>
</td>
I am selecting the span this way:
(css=span:contains("${SelectOrder}"))
where "SelectOrder" == From ORI-1730.
And tried to select the button with:
(css=span:contains("${SelectOrder}").prev())
without success.
I have found some themes, but was unable to make them work for me:
Jquery: Checking to see if div contains text, then action
Select previous element using jQuery selector only
Upvotes: 1
Views: 2120
Reputation: 52665
You can select required button by using XPath
instead of CSS
, like below:
xpath=//div[span[contains(text(), "${SelectOrder}")]]/button
Upvotes: 1