This question already has an answer here:
I have web element set like below ..
<div class="dxnb-headerCollapsed" id="ctl00_LeftPanel_LeftNavigationMenu_nbMenu_GHC1"> <i class="fa fa-handshake-o fa-2x fa-fw" style=""></i> My Team </div>
There, the number in GHC1 change depending on place, but text "My Team" is unique for particular set of element.
I tried to locate it with
By.XPATH,'//*[contains(@id,"ctl00_LeftPanel_LeftNavigationMenu_nbMenu_GHC") AND contains(text()="My Team")]'
But failed. How to do that correctly ? can not use by.text since "My Team" text could be exist in other parts of web page.