Home > Software design >  how to click driver find_element_by_xpath - not working
how to click driver find_element_by_xpath - not working

Time:03-06

<a  href="#" role="button"><span ></span></a>

How to click on this X icon using selenium python code

    elem = driver.find_element_by_xpath('//a[@]').click()
    elem.click()

I tried with this code but I got error

 Message: element not interactable

CodePudding user response:

You can try to add waiting

button = WebDriverWait(browser,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button.dismiss')))
button.click()

Or try to use js click

element = driver.find_element_by_xpath('//a[@]')

def js_click(self, element):
    driver.execute_script("arguments[0].click();", element)

CodePudding user response:

In your code

elem = driver.find_element_by_xpath('//a[@]').click()

you have used "Click" method, it won't return anything.

Just use this driver.find_element_by_xpath('//a[@]').click()

  • Related