I have the keyword "Know More" (using the keyword I find Xpath of that and performing actions like click) and the website has similar words like "Know More" for students loan, educational loan...etc which are not buttons but they are anchor tags. Now I want to click the "Know More" keyword using XPATH which is for "student loan" but student loan is available in block.
<div class="content">
<h5 class="mb-10">For Students</h5>
<h3>Enabling a hassle-free learning journey with curated solutions</h3>
<h4>#CampusPower #StudentLoan</h4>
<ul class="bullet-list bullet-list-orange mb-20">
<li>One stop solution for all your education needs</li>
<li>Customised product bundles for the country of your choice</li>
<li>Explore pre & post admission guidance</li>
<li>Learn how to manage your money.</li>
</ul>
<a id="ga-ese-whatsnew-1" href="/campus-power/student" class="ic-btn ic-btn-gradient">Know More</a>
</div>
I don't want to take manual Xpath so I used code based on Keyword Xpath lik this.
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, f"//*[contains(text(), '{keyword}')]"))
)
element.click()
It is clicking only the first "Know More" on the webpage which is for another loan. How to click on "Know More" for student loan any help on suggestion is appreciated. Thank You.