How can I get the ID of a paragraph when I pass text “Selection List” or “Deletion List”.
"<p id="section_548540600_title" class="CollapseExpand CollapseExpand_active" title="Collapse / Expand"><a href="javascript:void(0);">Selection List</a></p>"
"<p id="section_362548963_title" class="CollapseExpand CollapseExpand_active" title="Collapse / Expand"><a href="javascript:void(0);">Deletion List</a></p>"
Assuming I’ve understood your question correctly, you can use the
:containsselector to match elements based on their text content:Update
Note that the above approach assumes you only have a single element containing each string. If there are other elements containing the same strings, you may need a different approach to ensure the element contains only that string: