0

I am using selenium driver in python. I am trying to find and click a link web element located inside a dropdown menu. I used ActionChains to click and expand the dropdown menu and it works. But i am unable to find the link element and click on it. Upon clicking it will trigger a mail. I have used all find_element_by methods but nothing works.

html code

The code which i have used till now. It results in the No Element found error.

optionsmenu = driver.find_element_by_xpath('/html/body/div[3]/div[3]/div/div[2]/div[1]/div[3]/div[3]/table/tbody/tr/td[5]/a')
 

actions = ActionChains(driver)
actions.move_to_element(optionsmenu)
actions.click()
actions.perform()

print ('Options menu clicked')

driver.find_element_by_xpath('//*[@id="userOptionsMenu"]/td/ul/li[5]/a/span[2]').click()
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

1

The desired element is a React element so to click on the element you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "li.icon.Email > a span[data-bind$='resendWelcomeEmail']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//li[@class='icon Email']/a//span[contains(@data-bind, 'resendWelcomeEmail')]"))).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
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352