0

I am not sure what find_element_by_* I should use with respect to below "inspect element" to click on the download button. I am new to selenium still dealing with basics.

<a href="#" style="font-size:15px;" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.forms['activationpage3'],'activationpage3:j_id_id21,activationpage3:j_id_id21','');}return false">Download Key File</a>
DebanjanB
  • 118,661
  • 30
  • 168
  • 217
chetan honnavile
  • 342
  • 3
  • 15
  • I would recommend reading some guides/tutorials, and the docs. This kind of question ultimately has very little value both to the asker and to future readers. – AMC Jan 09 '20 at 02:58

2 Answers2

1

You can use the below.

driver.find_element_by_xpath("//a[.='Download Key File']").click()

enter image description here

supputuri
  • 12,238
  • 2
  • 14
  • 34
1

To click() on the element with text as Download Key File as it is an <a> node you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using LINK_TEXT:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.LINK_TEXT, "Download Key File"))).click()
    
  • Using PARTIAL_LINK_TEXT:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.PARTIAL_LINK_TEXT, "Download Key File"))).click()
    
  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[onclick*='activationpage3']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(@onclick,'activationpage3') and contains(., 'Download Key File')]"))).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
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217