studocu / codeception-mobileemulation

Codeception 的 WebDriver 移动仿真开关器

3.0.1 2022-07-26 12:12 UTC

This package is not auto-updated.

Last update: 2024-09-17 22:16:41 UTC


README

Software License Build Status Latest Stable Version

此 Codeception 模块可以在浏览器上实现移动仿真。目前仅支持 chrome 浏览器。

安装

您可以使用 composer 将此插件安装到您的应用中。

安装 composer 包的推荐方式是

composer require --dev studocu/codeception-mobileemulation

然后,在您的测试套件配置文件中启用此模块(例如:acceptance.suite.yml 等)

modules:
    enabled:
        - MobileEmulation
        - WebDriver

参见: 06-ModulesAndHelpers - Codeception - 文档

[重要] 应在 WebDriver 模块之前加载 MobileEmulation 模块。

使用方法

在您的 Cest 测试用例中,写入 $mobileEmulation 属性

class AwesomeCest
{
    public $mobileEmulation = true;

    // ...
}

$mobileEmulation = true 时,在此测试用例中启用移动仿真。

您可以使用 emulationMobile() 方法

class AwesomeCest
{
    public function tryYourSenario($I)
    {
        // enable mobile emulation manually, (with specific device name)
        $I->emulationMobile('iPhone 8 Plus');
        // ...
    }
}

配置选项

defaultDeviceName

默认仿真设备名称。

默认: 'iPhone 6'