tajawal/codeception-appium
Composer 安装命令:
composer require tajawal/codeception-appium
包简介
appium driver for codeception framework
关键字:
README 文档
README
Appium Driver for Codeception
Appium driver for codeception for writing mobile tests.
Requirement
- PHP >= 7.0
- Appium
- Inspect App with Appium Desktop
- Devices:
- Android
- iOS
- Install Xcode from the following link or run the following command
inside your terminal:
xcode-select --install
- Install the Carthage dependency manager:
brew install carthage
- Install Xcode from the following link or run the following command
inside your terminal:
Table of Contents
Install
Just add me-io/appium-driver-codeception to your project's composer.json file:
{
"require": {
"me-io/appium-driver-codeception": "~1"
}
}
and then run composer install. This will install codeception appium driver and all it's dependencies. Or run the following command
composer require me-io/appium-driver-codeception
Tests
Now lets run the following command at the root directory of your project:
codecept bootstrap
This command will creates a configuration file for codeception and tests directory and default test suites.
Writing tests for Android
Now, lets create a new configuration file android.suite.yml inside tests directory and put the following contents inside of it.
class_name: AndroidGuy modules: enabled: # Enable appium driver - \Appium\AppiumDriver - Asserts config: # Configuration for appium driver \Appium\AppiumDriver: host: 0.0.0.0 port: 4723 dummyRemote: false resetAfterSuite: true resetAfterCest: false resetAfterTest: false resetAfterStep: false capabilities: platformName: 'Android' deviceName: 'Android device' automationName: 'Appium' appPackage: io.selendroid.testapp fullReset: false noReset: false newCommandTimeout: 7200 nativeInstrumentsLib: true connection_timeout: 500 request_timeout: 500 autoAcceptAlerts: true appActivity: io.selendroid.testapp.HomeScreenActivity skipUnlock: true
Note:
deviceNameshould be set asAndroid deviceonly for real device. For Android Emulator use the name of the virtual device.
Writing tests for iOS
Now, lets create a new configuration file ios.suite.yml inside tests directory and put the following contents inside of it.
class_name: IosGuy modules: enabled: # Enable appium driver - \Appium\AppiumDriver - Asserts config: # Configuration for appium driver \Appium\AppiumDriver: host: 0.0.0.0 port: 4723 dummyRemote: false resetAfterSuite: true resetAfterCest: false resetAfterTest: false resetAfterStep: false capabilities: # PATH OF YOUR APP (something like /Users/username/Documents/ios.app) app: '' # xcideOrgId is Apple developer team identifier string. xcodeOrgId: '' # xcodeSigningId is a string representing a signing certificate. iPhone Developer by default. xcodeSigningId: 'iPhone Developer' platformName: 'iOS' platformVersion: '11.2' deviceName: 'iPhone8' # Your device udid udid: '' useNewWDA: false newCommandTimeout: 7200 automationName: 'XCUITest' autoAcceptAlerts: true fullReset: false noReset: true nativeInstrumentsLib: true connection_timeout: 500 request_timeout: 500 skipUnlock: true clearSystemFiles: true showIOSLog: true
Generating Actor classes
Now we need to generate actor class for the AndroidGuy/IosGuy that we defined in android.suite.yml/ios.suite.yml. To generate the actor class for AndroidGuy/IosGuy run the following command inside your terminal:
codecept build
Your First Android Test
To create your first android test create a new directory android inside tests folder. After creating the android folder create a new file FirstAndroidCest.php and put the following contents inside of it:
class FirstAndroidCest { public function changeLanguage(AndroidGuy $I) { $I->implicitWait([ 'ms' => 3500, ]); $text = $I->byId('id_of_button')->getText(); $I->assertEquals('Hello, World!', $text); } }
Your First iOS Test
To create your first iOS test create a new directory ios inside tests folder. After creating the ios directory create a new file FirstIosCest.php and put the following contents inside of it:
class FirstIosCest { public function lockPhone(Ios $I) { $I->implicitWait([ 'ms' => 10000, ]); $I->assertEquals('Hello, World!', 'Hello, World!'); $I->amGoingTo("lock phone"); $I->lock([null]); } }
Running tests
Run the appium server by running the following command:
appium
NOTE: If you want to change IP/Port run the appium command like this:
appium -a <IP Address> -p <Port>
After running the appium server now you need to start android emulator and install the application that you want to test. If you don't know how to start the emulator you can follow the following guide Setup Genymotion Android Emulators on Mac OS
Now run the following command inside your terminal to run the tests:
# For Android codecept run android FirstAndroidCest.php --steps # For iOS codecept run ios FirstIosCest.php --steps
Note: While following the steps that are mentioned here if you get
codecept command not founderror try to runcodeceptcommand like this./vendor/bin/codecept.
Contributors
A huge thanks to all of our contributors:
Mohamed Meabed 💻 📢 |
Zeeshan Ahmad 💻 🐛 ⚠️ 📖 |
|---|
License
The code is available under the MIT license.
tajawal/codeception-appium 适用场景与选型建议
tajawal/codeception-appium 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 160 次下载、GitHub Stars 达 19, 最近一次更新时间为 2017 年 07 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「BDD」 「TDD」 「unit testing」 「codeception」 「functional testing」 「acceptance testing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tajawal/codeception-appium 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tajawal/codeception-appium 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tajawal/codeception-appium 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Helper that decorates any SUS with a phpspec lazy object wrapper
Behat Context for testing Symfony Api
LazyPDO is a set of wrappers over PHP's standard PDO and PDOStatement classes. It enables lazy loading, serialization and decoration.
Provides access to magento2 object manager from behat and allows to change magento config settings temporarly
Symfony bundle for unigen test generator
A cli tool which generates unit tests.
统计信息
- 总下载量: 160
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-12