Click on "use" element Python Selenium

Viewed 61

I want to click on a button on ifunny.co using Python selenium, but the button isn't a button element, it's a "use" element. The code I usually use can't click this button. Please help. (I tried the click method two different ways). Also, I'm not sure if the "xlink:" is included in the attribute, but it doesn't work as "xlink:href" or "href". How do I click this button?

try:
    content = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//use[@xlink:href, '#icon_grid-full-size-active')]")))
    content.click()
    driver.find_element_by_xpath("//use[@xlink:href, '#icon_grid-full-size-active')]").click()

enter image description here

1 Answers

Try to execute click via javascript and execute_script driver function, like:

element = driver.find_element_by_xpath("//use[@xlink:href, '#icon_grid-full-size-active')]")
driver.execute_script("arguments[0].click();", element);
Related