Skip to content

Commit

Permalink
Fix for custom command and video length (#1174)
Browse files Browse the repository at this point in the history
* Add custom capability to customize video recording length

* Add plugin scripts to reset and setup

* Fix unknown command issue

* refactor troubleshooting

* bump version to 8.4.7-rc.40
  • Loading branch information
sudharsan-selvaraj authored Jun 12, 2024
1 parent d5931db commit 6e231ec
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 17 deletions.
3 changes: 2 additions & 1 deletion docs/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ title: Capabilities
---

| Capability Name | Description |
|------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| df:build | Allocate a build name in dashboard. Default value is `null`. |
| df:recordVideo | Enable video recording for the session. Default value is `true`. |
| df:videoTimeLimit | Maximum duration of the video recording in seconds. Default value is 1800 seconds (3 minutes). |
| df:iPhoneOnly | Allocate only iPhone simulators for execution when to true. Default value is `false`. |
| df:iPadOnly | Allocate only iPad simulators for execution when to true. Default value is `false`. |
| df:deviceAvailabilityTimeout | When create session requests are more than available connected devices, plugin waits for a certain interval for device availability before it timeout. Default value is `180000` milliseconds. |
Expand Down
36 changes: 26 additions & 10 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,35 @@ hide:
- navigation
---

### Device Farm

1. Facing errors related to prisma installation?

- run `appium plugin run device-farm setup`
- Check if the script executes without any error
- Incase of any error, open a new issue with the complete log from the script execution

2. How to delete all session details and videos?

- run `appium plugin run device-farm reset`
- The above command will delete all the existing data from database and resets the device farm to the original state

### IOS

1. How do I improve the iOS session startup for real device?
- Resign the WDA provided here: [WDA]()
- Use the following capabilities:
```json
{
'appium:usePreinstalledWDA': true,
'appium:updatedWDABundleId': wdaBundleID,
'appium:updatedWDABundleIdSuffix': '',
}
- Make sure the iPhone real device is unblocked and enabled developer mode.
- Resign the WDA provided here: [WDA]()
- Use the following capabilities:
```json
{
'appium:usePreinstalledWDA': true,
'appium:updatedWDABundleId': wdaBundleID,
'appium:updatedWDABundleIdSuffix': '',
}
```
- Make sure the iPhone real device is unblocked and enabled developer mode.
2. How do I improve the iOS session startup for Simulators?
- Provide server argument during the appium server start. `preBuildWDAPath` with the path to the WDA build for Simulators.
- Provide server argument during the appium server start. `preBuildWDAPath` with the path to the WDA build for Simulators.

### Notes

1. If there is no activity on a session for more then 100 seconds, device allocated to respective session would be unblocked and made available for new session requests.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appium-device-farm",
"version": "8.4.7-rc.39",
"version": "8.4.7-rc.40",
"description": "An appium 2.0 plugin that manages and create driver session on available devices",
"main": "./lib/src/main.js",
"scripts": {
Expand Down Expand Up @@ -288,6 +288,10 @@
},
"title": "Appium device farm plugin",
"type": "object"
},
"scripts": {
"setup": "lib/src/scripts/setup-db.js",
"reset": "lib/src/scripts/clear-assets.js"
}
},
"engines": {
Expand Down
1 change: 1 addition & 0 deletions src/CapabilityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum DEVICE_FARM_CAPABILITIES {
SESSION_NAME = 'name',
VIDEO_RECORDING = 'recordVideo',
VIDEO_RESOLUTION = 'videoResolution',
VIDEO_TIME_LIMIT = 'videoTimeLimit',
LIVE_VIDEO = 'liveVideo',
SCREENSHOT_ON_FAILURE = 'screenshotOnFailure',
DEVICE_FARM_OPTIONS = 'df:options',
Expand Down
2 changes: 1 addition & 1 deletion src/modules
14 changes: 14 additions & 0 deletions src/scripts/clear-assets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import fs from 'fs';
import { config } from '../config';
import { executeCmd } from './initialize-database';

async function main() {
if (fs.existsSync(config.cacheDir)) {
fs.rmdirSync(config.cacheDir, { recursive: true });
}
fs.mkdirSync(config.cacheDir, { recursive: true });

executeCmd('npm run run-db-migration');
}

(async () => await main())();
8 changes: 6 additions & 2 deletions src/scripts/initialize-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const env = {
DATABASE_URL: `file:${config.databasePath}`,
};

function executeCmd(cmd: string) {
export function executeCmd(cmd: string) {
try {
execSync(cmd, {
env,
Expand All @@ -26,4 +26,8 @@ async function main() {
executeCmd('prisma generate');
}

(async () => await main())();
if (require.main === module) {
(async () => await main())();
}

export default main;
7 changes: 7 additions & 0 deletions src/scripts/setup-db.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { executeCmd } from './initialize-database';

async function main() {
executeCmd('npm run run-db-migration');
}

(async () => await main())();

0 comments on commit 6e231ec

Please sign in to comment.