Home > Back-end >  Selenium: How to click a label
Selenium: How to click a label

Time:01-28

I'm trying to click this object with selenium (pyhton) using the code:

driver.find_element_by_('publicForm_customFields').click()

But I'm receiving this error:

id="publicForm_customFields" tabindex="0" type="radio" value="value"> is not clickable at point (480, 98). Other element would receive the click: value

CodePudding user response:

"Other element would receive the click" means that you have another element over your element. There are a couple of options to get around this:

  1. Try to find another element above in the DOM tree and click on it.
  2. Use js click, you need to write a function like this:
 def js_click(self, element):
        element = driver.find_element_by_id("myid")
        driver.execute_script("arguments[0].click();", element)

js script will click on the element even if it is intersected by another

CodePudding user response:

There might be two possibilities:

1- Your locator to find element might be wrong or not unique. 2- You need to apply explicit wait till element is ready [load successfully] to be clickable.

Hope above possibilities might help you out, Or you share the link of the sight so I might debug correctly.

CodePudding user response:

You are not passing any find method to the driver. Try refactoring the code to:

driver.find_element_by_id('publicForm_customFields').click()

Also, try using some sort of wait so the driver does not click before the page/element is loaded.


from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.ID, 'publicForm_customFields'))).click()

  •  Tags:  
  • Related