I've been trying to click a button using selenium package in python. I've been having trouble figuring out how to identify the button, though. After way too much time, I tried manually copying the xpath
from the javascript console, but get a NoSuchElementException
when I try to call driver.find_element_from_xpath('<xpath>')
.
I'm really not sure how that's possible. The HTML is extremely long - what I'm ultimately trying to locate is nested under multiple table, body, td, tr tags. Here's the element though:
<a href="Javascript:void" onclick="javascript:toggleDisplay(this, trAK);return false;">Alaska</a>
When I clicked "Copy Xpath" in Chrome, it returned this string: //*[@id="Form1"]/table/tbody/tr[3]/td/table/tbody/tr[1]/td/table/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr[5]/td/table/tbody/tr[3]/td/table[1]/tbody/tr[1]/td[2]/a
I'm pretty new to this so can anyone help me understand why this won't work and/or what I could do to fix it?