python中的Selenium在单击隐藏单选按钮时出现问题

2024-09-19 23:27:22 发布

您现在位置:Python中文网/ 问答频道 /正文

使用driver.find_元素()可以定位按钮,但在此之后,我使用click()然后弹出一些错误,如下所示:

  File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webelement.py", line 65, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webelement.py", line 385, in _execute
    return self._parent.execute(command, params)
  File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 173, in execute
    self.error_handler.check_response(response)
  File "C:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 166, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: 'Element is not currently visible and so may not be interacted with' ; Stacktrace: 
    at fxdriver.preconditions.visible (file:///C:/Users/LIANGD~1/AppData/Local/Temp/tmp_hdmf0mu/extensions/fxdriver@googlecode.com/components/command-processor.js:8936:5)
    at DelayedCommand.prototype.checkPreconditions_ (file:///C:/Users/LIANGD~1/AppData/Local/Temp/tmp_hdmf0mu/extensions/fxdriver@googlecode.com/components/command-processor.js:11595:1)
    at DelayedCommand.prototype.executeInternal_/h (file:///C:/Users/LIANGD~1/AppData/Local/Temp/tmp_hdmf0mu/extensions/fxdriver@googlecode.com/components/command-processor.js:11612:11)
    at DelayedCommand.prototype.executeInternal_ (file:///C:/Users/LIANGD~1/AppData/Local/Temp/tmp_hdmf0mu/extensions/fxdriver@googlecode.com/components/command-processor.js:11617:7)
    at DelayedCommand.prototype.execute/< (file:///C:/Users/LIANGD~1/AppData/Local/Temp/tmp_hdmf0mu/extensions/fxdriver@googlecode.com/components/command-processor.js:11559:5) 

为什么会这样?在


Tags: executelocalseleniumextensionsusersappdatatemptmp
1条回答
网友
1楼 · 发布于 2024-09-19 23:27:22

错误消息告诉您发生这种情况的确切原因:

Element is not currently visible and so may not be interacted with

Selenium只允许您与可见元素交互,前提是如果它是不可见的,那么用户不能与它交互,如果用户不能与它交互,那么Selenium也不能。在

相关问题 更多 >