jej*_*343 17 python django selenium django-testing selenium-webdriver
在我的Django项目上运行Selenium测试时,我开始收到错误:
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>
Run Code Online (Sandbox Code Playgroud)
奇怪的是有两个原因:第一,先前通过的测试,我没有编辑代码库的那部分.其次,当弹出Selenium驱动的Firefox窗口并且我最大化页面时,测试通过.但是当我让Selenium测试在Firefox浏览器没有最大化的情况下运行时,它们会失败.
我没有使用任何花哨的javascript(只是基本的Bootstrap 3模板),只是普通的旧HTML和CSS.我在Python 3.4上使用Django 1.9.我已经运行了pip来检查Selenium的升级,而且我是最新的.
这是我的视图和模板输出的html的pastebin链接.
其中一项失败的测试是:
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()
Run Code Online (Sandbox Code Playgroud)
最后一行产生错误:
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>
Run Code Online (Sandbox Code Playgroud)
Maj*_*jor 22
聚会非常晚,但我有一个非常简单的解决方案,对我有用.不要做.click(),而只是做
.send_keys(selenium.webdriver.common.keys.Keys.SPACE)
Run Code Online (Sandbox Code Playgroud)
选中元素后,空格键可以切换选择.为我工作!
小智 10
你的答案在于你的问题.
not clickable at point - (61, 24.300003051757812)这是另一个元素 - Other element would receive the click: <a class="navbar-brand" href="#"></a> 尝试点击的地方.由于您没有最大化浏览器,因此无法正确获得点坐标.| 归档时间: |
|
| 查看次数: |
21626 次 |
| 最近记录: |