When running Selenium tests on my Django project, I've started to get the error:
selenium.common.exceptions.WebDriverException: Message: Element is not clickable at point (61, 24.300003051757812). Other element would receive the click: <a class="navbar-brand" href="#"></a>
It is odd for two reasons: First, the tests previously passed and I have not edited that part of the code base. Second, when the Selenium-driven Firefox Window pops up and I maximize the page, the tests pass. But when I let the Selenium tests run with the Firefox browser not maximized, they fail.
I'm not using any fancy javascript (just the basic Bootstrap 3 template), just plain old html and css. I'm using Django 1.9 on Python 3.4. I've run pip to check for upgrades to Selenium, and I'm up to date.
Here is a pastebin link to the html of the output of my view and template.
One of the failing tests is:
def test_create_task_and_check_that_it_shows_up_in_the_task_manager_index_and_filter(self):
# Create user
self.user = User.objects.get(username=test_superuser_username)
# Log the user in
self.log_user_in(user_object=self.user, password=test_superuser_password)
self.browser.implicitly_wait(10)
# Pull up the main task manager page
self.browser.get(str(self.live_server_url) + reverse('task_manager:index'))
# Make sure we go to the task manager index
task_index_url = str(self.live_server_url) + reverse('task_manager:index')
self.browser.get(task_index_url)
self.browser.implicitly_wait(4)
self.assertTrue(str(task_index_url) == self.browser.current_url,
msg=('Assertion that current_url is %s failed. Current_url is %s' %
(str(reverse('task_manager:index')), self.browser.current_url)))
# Click the 'add task' button on the sidebar
add_task_taskbar_button = self.browser.find_element_by_name('add_task_sidebar_link')
add_task_taskbar_button.click()
The last line produces the error:
ERROR: test_create_task_and_check_that_it_shows_up_in_the_task_manager_index_and_filter (tasks.tests.test_functional.SeleniumTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/mint/Python_Projects/[project_name]/tasks/tests/test_functional.py", line 94, in test_create_task_and_check_that_it_shows_up_in_the_task_manager_index_and_filter
add_task_taskbar_button.click()
File "/home/mint/Python_Projects/venv/lib/python3.4/site-packages/selenium/webdriver/remote/webelement.py", line 75, in click
self._execute(Command.CLICK_ELEMENT)
File "/home/mint/Python_Projects/venv/lib/python3.4/site-packages/selenium/webdriver/remote/webelement.py", line 469, in _execute
return self._parent.execute(command, params)
File "/home/mint/Python_Projects/venv/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "/home/mint/Python_Projects/venv/lib/python3.4/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Element is not clickable at point (61, 24.300003051757812). Other element would receive the click: <a class="navbar-brand" href="#"></a>
Extremely late to the party, but I have an extremely simple solution that worked for me. Instead of doing .click(), simply do
.send_keys(selenium.webdriver.common.keys.Keys.SPACE)
With the element selected, the spacebar can toggle the selection. Worked for me!