hey guys,
im currently trying to acces a link via Selenium. The Link named 'Ansehen' exists X amount of times, so the only difference in the source code between them is the string in the brackets of its
<a href="#" onclick="doRetrievePnr('C2YK79')" id="viewPnr">Ansehen</a>
The String in the Brackets (('C2YK79')) is the only difference between all the Links with the name "Ansehen".
i tried all the methods with Selenium to click on that but i am failing. I think it has something to do with the string in the brackets?
Heres my Function:
(if doesnt work: https://ibb.co/Gp68fh7 )
if doesnt work again:
Thanks
im currently trying to acces a link via Selenium. The Link named 'Ansehen' exists X amount of times, so the only difference in the source code between them is the string in the brackets of its
onclick
<a href="#" onclick="doRetrievePnr('C2YK79')" id="viewPnr">Ansehen</a>
The String in the Brackets (('C2YK79')) is the only difference between all the Links with the name "Ansehen".
i tried all the methods with Selenium to click on that but i am failing. I think it has something to do with the string in the brackets?
Heres my Function:
def log_in_and_OPTIONALISIERT(): driver = webdriver.Chrome(path) driver.maximize_window() driver.get(url) driver.find_element_by_name("agencyCode").send_keys(agentur_code) driver.find_element_by_name("agencyId").send_keys(Agent_ID) driver.find_element_by_name("password").send_keys(Passwort) driver.find_element_by_xpath('//button[@type="button"]').click() #driver.find_element_by_xpath('//button[@onclick="togglesidebar(event)"]').click() driver.find_element_by_link_text("PRRN Buchungssuche").click() element = driver.find_element_by_id("bl_payment_status_chosen").click() driver.find_element_by_xpath('//li[@data-option-array-index="2"]').click() driver.find_element_by_id("proceed").click() driver.implicitly_wait(5) # PROBLEM STARTS HERE # FIRST TRY driver.find_element_by_link_text("doRetrievePnr('C2YK79')").click() # SECOND TRY driver.find_element_by_xpath("//a[contains(@onclick,'doRetrievePnr('C2YK79')']").click()source code!!!:
if doesnt work again:
1. link <td class="text-right"> <a href="#" onclick="doRetrievePnr('C2YK79')" id="viewPnr">Ansehen</a></td> 2. link <td class="text-right"> <a href="#" onclick="doRetrievePnr('U3DD99')" id="viewPnr">Ansehen</a></td>Following Error occurs:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"link text","selector":"doRetrievePnr('C2YK79')"
Thanks

