0

在我的 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

仅供参考,我正在使用 marionette-driver 1.1.1

任何有关解决此问题的建议将不胜感激。


2018 年 10 月 26 日编辑

它现在返回一条不同的错误消息:

$ 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
4

1 回答 1

0

这可能是由于此处回答的驱动程序过时:WebDriver Error New Session

如果它不是与 Repo 相关的,那么可能是因为.pyc文件滞留并且 python 在重新编译之前尝试先使用它们。

  • 基本上你会找到相关的.pyc文件然后删除,以便重新编译源代码。检查此打开的错误以获取更多信息。

谢谢你。再会。

于 2018-10-25T15:42:04.273 回答