html – Unable to click on a menu item_Selenium-ThrowExceptions

Exception or error:

UI Looks like this

I have a menu item shown as ‘+’ and the text next to that item is ‘A Menu’. Basically, i am trying to click on ‘A Menu’ using ‘+’ next to it by using the selenium script, but i am unable to locate it.

Once, it is clicked, i need to click another sub-menu item called ‘C Menu’ underneath it.

HTML looks like below

<tr xpath="1">
<td><a href="javascript:__doPostBack('ctl00$LeftMenu1$LinksTreeView','tASS_MAIN')"><img src="//Testing/Web/WebResource.axd?d=-n2KnhPEOy8tY2UhU96Dmw0eWWhG7MAtPVOAxmDMFz3i2seUZCIcO5caO6DjNzjQDb49U_8_Pn7VGwq-nQI6VOPtUd13XoJiE3xuwQjDAXI1&amp;t=636940313766230707" alt="Collapse Associates Menu" title="Collapse Associates Menu" style="border-width:0;"></a>
</td><td class="menu-text trx" style="white-space:nowrap;padding:8px 2px 8px 2px;"><a class="menu-text trx" href="javascript:__doPostBack('ctl00$LeftMenu1$LinksTreeView','sASS_MAIN')" id="LeftMenu1_LinksTreeViewt2" style="color:Black;font-family:Verdana;font-size:10pt;text-decoration:none;border-style:none;">Associates Menu</a></td>
		</tr>

I have written the following code

driver.findElement(By.xpath(“//a[@id=’LeftMenu1_LinksTreeViewt2′]”)).click();

But, it is not working. Any suggestions?

How to solve:

Could you please put the UI like it looks like here? It will me much easier to help.

Leave a Reply

Your email address will not be published. Required fields are marked *