I want to click the element with highest data-id. I'm generating title like this:
char_set = string.ascii_uppercase
tagTitle = "AI TAG " + ''.join(random.sample(char_set * 4, 4))
driver.find_element_by_xpath("//*[@id='FolderName']").send_keys(tagTitle)
Currently I'm getting all elements of UI class:
driver.find_element_by_xpath("/html/body/div[2]/div[2]/div[1]/div[1]/div/div[2]/ul/li")
<ul class="investorGroup ul-groups">
<li data-id="-1" class="">
<a href="javascript:void(0)" onclick="$.InvestorContact.Group.LoadGroupInvestorsOnGroupClick(-1,null, 0)">Master</a>
</li>
<li title="AI TAG AOAI" data-id="371">
<a href="javascript:void(0)" onclick="$.InvestorContact.Group.LoadGroupInvestorsOnGroupClick(371)">2451b 24 (<span class="contactCatCount">0</span>)</a>
<a href="javascript:$.InvestorContact.Group.OpenAddGroupModal(371)" class="edit"><i class="fa fa-pencil" aria-hidden="true"></i></a>
</li>
<li title="AI TAG CANG" data-id="376" >
<a href="javascript:void(0)" onclick="$.InvestorContact.Group.LoadGroupInvestorsOnGroupClick(376)">452352 (<span class="contactCatCount">0</span>)</a>
<a href="javascript:$.InvestorContact.Group.OpenAddGroupModal(376)" class="edit"><i class="fa fa-pencil" aria-hidden="true"></i></a>
</li>
</ul>
now tried and its showing the element :
$x('/html/body/div2/div2/div1/div1/div/div2/ul/li[contains(@title,"AI TAG FOVE")]')
but does not click and gives error via python:
TagElement = driver.find_element_by_xpath('/html/body/div2/div2/div1/div1/div/div2/ul/li[contains(@title,"AI TAG FOVE")]') TagElement.click()
sorry if i skip something just a learner here.
selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element ... is not clickable at point (122, 388). Other element would receive the click: ... (Session info: chrome=80.0.3987.132)

First you can get all the elements in a list and then you can click on the last element because that would be having the highest
data-idand if you want to get the title which you are clicking then you can get it by usingget_attribute()method.You can do it like:
Edited ans for picking text from a variable:
Now fetch the list by using: