I am trying to automate a process using python and the selenium library.
The item I need to click on is: "In charge LIFE - Individual-risk recruitment".
This is the entire hierarchical structure of the HTML starting with the table id
<table id="contentArea" border="0" cellpadding="0" cellspacing="0" xpath="1">
<tbody>
<tr>
<td class="leftNavBg" style="width: 150px">
<table border="0" cellspacing="0" cellpadding="0" id="leftNav" statusfield="ctl00_mb_menu1_status">
<tbody>
<tr></tr>
<tr class="leftNavBg3" style="DISPLAY: block"></tr>
<tr style="DISPLAY: block"></tr>
<tr class="leftNavBg1" style="DISPLAY: block"></tr>
<tr style="DISPLAY: block"></tr>
<tr class="leftNavBg1" style="DISPLAY: block"></tr>
<tr style="DISPLAY: block"></tr>
<tr class="leftNavBg1" style="DISPLAY: block"></tr>
<tr style="DISPLAY: block"></tr>
<tr style="DISPLAY: block"></tr>
<tr class="leftNavBg3" style="DISPLAY: block"></tr>
<tr style="DISPLAY: block"></tr>
<tr class="leftNavBg1" style="DISPLAY: block"></tr>
<tr style="DISPLAY: block" childnum="6"></tr>
<tr class="leftNavBg2" liv="2" style="DISPLAY: none"></tr>
<tr style="DISPLAY: none" liv="2"></tr>
<tr class="leftNavBg2" liv="2" style="DISPLAY: none"></tr>
<tr style="DISPLAY: none" liv="2"></tr>
<tr class="leftNavBg2" liv="2" style="DISPLAY: none"></tr>
<tr style="DISPLAY: none" liv="2"></tr>
<tr class="leftNavBg1" style="DISPLAY: block"></tr>
<tr style="DISPLAY: block"></tr>
<tr style="DISPLAY: block"></tr>
<tr class="leftNavBg3" style="DISPLAY: block"></tr>
<tr style="DISPLAY: block"></tr>
<tr class="leftNavBg1" style="DISPLAY: block">
<td></td>
<td valign="top"></td>
<td colspan="3" class="navText" align="left" style="width:133px;">
<a class="navText" href="#" onclick="switch_menu(this, 6, 2);return false;">
In charge LIFE - Individual-risk recruitment.
</a>
</td>
</tr>
Can anyone help me with this?
Thank you all.
I try this:
try:
element = driver.find_element(By.XPATH, "//table[@id='contentArea']//table[@id='leftNav']//tr[@class='leftNavBg1']//td[contains(@class, 'navText') and contains(text(), 'In charge LIFE - Individual-risk recruitment')]")
print("Element found:", element)
except NoSuchElementException:
print("Element not found")