跳转到主要内容

Mobly Windows控制器模块,用于在Mobly测试中使用Python代码操作Windows设备

项目描述

Mobly Windows控制器

Mobly Windows控制器模块,用于在Mobly测试中使用Python代码操作Windows设备。

要求

  • Python 3.7+
  • Mobly 1.12.2+

安装

pip install mobly-windows

开始使用

Mobly Windows控制器是用于在Mobly中控制Windows设备的附加模块。要了解更多关于Mobly的信息,请访问Mobly入门教程

编写Mobly设备配置

要在Mobly测试中使用Windows设备,首先您需要编写一个配置文件来指定测试设备的详细信息。例如

sample_config.yaml

TestBeds:
- Name: SampleWindowsTestbed
  Controllers:
    WindowsDevice:
    - device_id: 'DEVICE_ID'
      hostname: 'IP_ADDRESS'
      username: 'USERNAME'
      password: 'PASSWORD'

注意:将DEVICE_IDIP_ADDRESSUSERNAMEPASSWORD替换为您的设备信息。

编写Hello World Mobly测试

hello_world_test.py

"""A basic Mobly Test with Windows device."""

from mobly import base_test
from mobly import test_runner
from mobly.controllers.windows import windows_device


class HelloWorldTest(base_test.BaseTestClass):
  """A sample test demonstrating using Mobly Windows controller."""

  def setup_class(self):
    super().setup_class()
    # Registers windows_device controller module. By default, we expect at
    # least one Windows device.
    self._wind = self.register_controller(windows_device)[0]

  def test_ssh_execute_command(self):
    # Executes console command 'SYSTEMINFO' on the Windows device and gets the result.
    result = self._wind.ssh.execute_command('SYSTEMINFO')
    self._wind.log.info('Command execution result: %s', result)


if __name__ == '__main__':
  test_runner.main()

执行测试

python hello_world_test.py -c sample_config.yaml

预期:测试的Windows设备的系统信息将记录在您的控制台上。

项目详情


下载文件

下载您平台对应的文件。如果您不确定该选择哪个,请了解更多关于 安装包 的信息。

源代码发行版

mobly-windows-1.0.0.tar.gz (34.3 kB 查看哈希值)

上传时间 源代码

构建发行版

mobly_windows-1.0.0-py3-none-any.whl (37.7 kB 查看哈希值)

上传时间 Python 3

支持者