Selenium webdriver is not finding the Inbox element

Bumping this from two months ago since I have not found a solution. I am using Firefox driver to find and then click on a hyperlink named "Inbox" but after exhaustive attempts, Selenium still can't find the element. Any help would be appreciated as I genuinely have not been able to find a reason why Selenium webdriver cannot find the element.

In the below HTML code, I have considered that there might be a frame but none can be found; if someone could confirm that there in fact is no iframe in the below code that would be appreciated! I also already have a time.sleep(40) in my script to allow for enough time for webdriver to find the element. So I am running out of ideas, but was thinking that maybe the #text element ("    &nbsp") right before the "inbox" hyperlink element might be causing the issue by hiding the "inbox" element? Any tips on how to proceed would be appreciated; all my attempts at resolution are listed below.

Below is my code up until this element issue comes up (URL has been removed as it is proprietary):

from selenium import webdriver
import time

driver = webdriver.Firefox()
driver.get("[URL REMOVED]")
time.sleep(2)
elem1 = driver.find_element_by_css_selector('#main-content > div > div.col-md-4.radix-layouts-sidebar.sidebar-right.panel-panel.sidebar > div > div.panel-pane.pane-entity-field.pane-it-service-field-related-services.block > div > div > ul > li:nth-child(1) > a')
elem1.click()
#Logging in
time.sleep(40)
#Now in the System, click on Inbox Button
elem2 = driver.find_element_by_??? # Trying to figure out this code to find inbox element
elem2.click()

I have tried the below in trying to find the element :

find_element_by_xpath('//td[@class=’MENUCHOICE’]//a[@href="main.do?action=inbox"]')
find_element_by_xpath('/html/body/table/tbody/tr[6]/td/a')
find_element_by_link_text('Inbox')
find_element_by_partial_link_text('Inb')
find_element_by_css_selector('body > table > tbody > tr:nth-child(6) > td > a')
find_element_by_css_selector("td.MENUCHOICE a[href='main.do?action=inbox']")

All the locators I have tried raise 'selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element'

I cannot provide the link to the page as it's proprietary, but below I have provided the page HTML in case someone can assist (The element of interest is under the second to last MENUCHOICE class: Inbox):

 <html>
   <!--702.15-->
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta http-equiv="Cache-Control" content="no-cache">
      <meta http-equiv="Expires" content="0">
      <meta http-equiv="Pragma" content="no-cache">
      <title>UDM - Notification System</title>
      <style type="text/css">
         td.MENU1 {
         FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
         FONT-SIZE: 18pt;
         FONT-WEIGHT: medium;
         color: navy;
         }
         td.MENU2 {
         FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
         FONT-SIZE: 15pt;
         FONT-WEIGHT: medium;
         color: navy;
         }
         td.MENUCHOICE {
         FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
         FONT-SIZE: 14pt;
         FONT-WEIGHT: medium;
         color: blue;
         }
      </style>
   </head>
   <body bgcolor="#ffffff" background="payadm/images/background.gif">
      <table width="750" border="0">
      <tbody>
         <tr>
            <td><img height="55" width="129" src="payadm/images/udm_cw100.gif"></td>
         </tr>
         <tr>
            <td>&nbsp;<img src="payadm/images/footerline.gif"></td>
         </tr>
         <tr>
            <td class="MENU1">&nbsp;&nbsp;AN Main Menu</td>
         </tr>
         <tr>
            <td> &nbsp;</td>
         </tr>
         <tr>
            <td class="MENUCHOICE">&nbsp;&nbsp;&nbsp;Notification Functions:</td>
         </tr>
         <tr>
            <td class="MENUCHOICE">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <a href="main.do?action=inbox">Inbox</a>
            </td>
         </tr>
         <tr>
            <td class="MENUCHOICE">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <a href="main.do?action=notificationSel">Notification Selection</a>        
            </td>
         </tr>

Thanks for the help.

728x90

1 Answers Selenium webdriver is not finding the Inbox element

To click the element with text as Inbox you can use either of the following solutions:

  • css_selector:

    find_element_by_css_selector("td.MENUCHOICE a[href='main.do?action=inbox']")
    
  • xpath:

    find_element_by_xpath("//td[@class='MENUCHOICE']//a[@href='main.do?action=inbox' and contains(.,'Inbox')]")
    

2 months ago