-3

Using driver.find_element_by_xpath() can locate the button, but after this I use click() then pop up some error as below:

  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) 

Why would this happen?

Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
dong liang
  • 33
  • 1
  • 1
  • 5

1 Answers1

0

The error message is telling you exactly why this would happen:

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

Selenium will only let you interact with visible elements, under the assumption that if it's invisible then the user can't interact with it, and if the user can't interact with it neither can selenium.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • you are right. so how can I correct my code? the next radio buttons will not show up unless you press the previous one. I have already click the previous button and see the next button show up on the website – dong liang Nov 09 '14 at 03:30
  • I have tried implicitly_wait() to wait the button show up, then press it. still not work – dong liang Nov 09 '14 at 03:33
  • I am sorry that misleading you. base some conditions (such as I have press other buttons), the invisible button has already become visible on website. I have tried WebDriverWait...until, still cannot interact with it. Do you have any samples about this? thanks so much! – dong liang Nov 11 '14 at 04:51