I'm using Selenium with Python 3.5 to automate a process I do on a regular basis. However, I need to invoke a drop-down list by clicking a button on the header of the website. I've tried so many times to make this thing work but this is frustrating. I've tried to find the element by "ID","class", and directly copying the xpath into the code. I'm fairly new to this so any help is greatly appreciated! The truncated version of my code is:
SwitchOffices = driver.find_element_by_xpath('//*[@id="tdSwitchOff"]/a').click()
Here is the HTML code that I've highlighted on the selected item that will trigger the drop-down list:
<a class="BannerMessage" style="cursor: pointer; color: blue;
text-decoration: none;" onclick="JavaScript:fnShowBUList();"
onmouseout="this.style.textDecoration='none';"
onmouseover="this.style.textDecoration='underline';">
Switch Offices </a>
Not sure if this matters but this is the HTML code that is above the xpath that I want to put in my code.
<div id="tdSwitchOff" valign="top" style="float: right; visibility:
visible; display: inline;">
<a class="BannerMessage"
style="cursor: pointer; color: blue; text-decoration: none;"
onclick="JavaScript:fnShowBUList();" onmouseout="this.style.textDecoration='none';"
onmouseover="this.style.textDecoration='underline';">
Switch Offices </a> |
</div>
Running my Selenium code against the HTML provided produces a NoSuchElementException.
NoSuchElementException, or does nothing happen at all? Knowing what the error message is (if any) will help track down the issue.