I'm trying to select dynamic links in a JavaScript table using Selenium. Here is sample HTML code for one of the links I'm trying to click:
<a href="#" onclick="javascript: runCategoryReport(0,"objectName=enrollee&titleMessageKey=3-3-2&time=month&systemTypeMetaId=6&categoryName=Attendee");">1925</a>
I've tried the following lines of code separately to click this specific link:
Option 1
driver.find_element_by_xpath("//a/*[contains(text(), '3-3-2')]").click()
Option 2
driver.find_element_by_xpath("//a[contains(@onclick, '3-3-2')]").click()
Both lines of code result in errors:
NoSuchElementException: Message: no such element: Unable to locate element {"method":"xpath","selector":"//a/*[contains(text(), '3-3-2')]"} (Session info: chrome=90.0.4430.212)
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//a[contains(@onclick, '3-3-2')]"}
(Session info: chrome=90.0.4430.212)
I'd appreciate any kind of feedback on this issue.