在我的Python脚本中,我试图通过Marionette驱动程序设置一些手机设置。我正在导入以下内容:
from marionette_driver import By
from marionette_driver import Wait
from marionette import Marionette
然后我尝试用设备打开客户端会话:
client = Marionette('localhost', port=2828)
client.start_session()
但是,我收到UnknownCommandException:
Traceback (most recent call last):
File "xyz.py", line 30, in <module>
client.start_session()
File "/usr/local/lib/python2.7/dist-packages/marionette_driver/decorators.py", line 26, in _
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/marionette_driver/marionette.py", line 1243, in start_session
body)
File "/usr/local/lib/python2.7/dist-packages/marionette_driver/decorators.py", line 26, in _
return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/marionette_driver/marionette.py", line 741, in _send_message
self._handle_error(err)
File "/usr/local/lib/python2.7/dist-packages/marionette_driver/marionette.py", line 765, in _handle_error
raise errors.lookup(error)(message, stacktrace=stacktrace)
marionette_driver.errors.UnknownCommandException: WebDriver:NewSession
仅供参考,我使用的是牵线木偶驱动程序1.1.1
非常感谢任何有关解决此问题的建议。
于10/26/2018编辑
现在返回一条不同的错误消息:
$ python
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from marionette import Marionette
Traceback (most recent call last):
File "./xyz.py", line 7, in <module>
from marionette import Marionette
File "/usr/local/lib/python2.7/dist-packages/marionette/__init__.py", line 7, in <module>
from .marionette_test import (
ImportError: No module named marionette_test
答案 0 :(得分:0)
这可能是由于此处的驱动程序已过期:WebDriver Error New Session
如果与回购无关,则可能是因为 .pyc 文件持续存在,而python尝试在重新编译之前先使用它们。
谢谢。美好的一天。