1

从命令行使用 python,我执行以下命令:

driver = webdriver.Firefox()
driver.get('http://amazon.com/mp3')
el = driver.find_element_by_link_text('MP3 Downloads : MP3 Songs')
el.click()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\selenium-2.19.1-py2.7.egg\selenium\webdriver\remote\webelement.py", line 45, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\Python27\lib\site-packages\selenium-2.19.1-py2.7.egg\selenium\webdriver\remote\webelement.py", line 194, in _execute
    return self._parent.execute(command, params)
  File "C:\Python27\lib\site-packages\selenium-2.19.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 153, in execute
    self.error_handler.check_response(response)
  File "C:\Python27\lib\site-packages\selenium-2.19.1-py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 147, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: u'current is undefined'

我不知道“当前”是什么......我在另一台机器上运行它,错误变成了

...Message u'l is undefined'

有什么建议么?顺便说一句,这只发生在 Firefox 上的 Windows 上。

4

1 回答 1

0

单击按钮时,我遇到了同样的问题。

您可以通过发送“空格”字符来单击它:

webDriver.FindElement("button_id").SendKeys(" ");

希望能帮助到你!

于 2012-08-07T16:12:49.010 回答