0

Please need your support to click on a link in the following:

enter image description here

I tried the below code but doesn't work:

web.find_element(By.XPATH,'//*[@id="HUI_i_0"]/table/tbody/tr/td/a').click()

It gives me error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="HUI_i_0"]/table/tbody/tr/td/a"}
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

0

Try to use link text to locate element:

web.find_element(By.LINK_TEXT,'Subscriber Administration').click()

If link is dynamic try to add wait

JaSON
  • 4,843
  • 2
  • 8
  • 15
0

The desired element is a dynamic element, so to click() on the clickable element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following locator strategies:

  • Using PARTIAL_LINK_TEXT:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, "tbody > tr > td.treeNode > a"))).click()
    
  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a.btn.signin-btn.sbLoginBtn > span.btf-text"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(., 'Subscriber Administration')]"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    

References

You can find a couple of relevant discussions on NoSuchElementException in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352