Recently I have faced an issue with selenium web driver (python) for checkbox and radio button click action.

The issue was when the driver tried to click on an element which is a checkbox or a radio button, it shows an error saying “element not clickable at point…”.

We googled for the issue and found that was a chrome driver related issue where in that cases the driver can not scroll to that element position.

To solve this problem I have located the X,Y position of the element (checkbox or radio button) and scroll that Y position and then perform the click action.

Then its work’s like a charm!

Here the Sample code we have used to create an application for a page and the application form is very long (need to scroll to see all the fields). I used that location scrolling technique to resolve the checkbox radio button issue.

 
..................
#checkbox list action issue#
print driver.find_element_by_id("edit-field-file-data-analysis-tools-und-0-upload").location
driver.execute_script("window.scrollTo(0, 8926)")
driver.find_element_by_id("edit-field-quality-improvement-und-box-and-whisker-plot").click()
driver.find_element_by_id("edit-field-file-box-and-whisker-plot-und-0-upload").clear()
..................

Here “edit-field-file-data-analysis-tools-und-0-upload” is our checkbox element.
I have printed the X, Y value using

print driver.find_element_by_id("edit-field-file-data-analysis-tools-und-0-upload").location

.
Then the output shows error with the X,Y value, where the Y value was “8926”. Then I have use

driver.execute_script("window.scrollTo(0, 8926)")

to scroll down to the element position.
Then the click action using:

 driver.find_element_by_id("edit-field-quality-improvement-und-box-and-whisker-plot").click()

 

Advertisements