diff --git a/packages/cli/README.md b/packages/cli/README.md index 21f3e03..1eae265 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -5,7 +5,7 @@ [![CI](https://github.com/Foreverskyin0216/playword/actions/workflows/ci.yml/badge.svg)](https://github.com/Foreverskyin0216/playword/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/Foreverskyin0216/playword/graph/badge.svg?token=8VO1EFXKDI)](https://codecov.io/gh/Foreverskyin0216/playword) -Enable you to execute PlayWord tests directly from the command line. +Enable you to use PlayWord directly from the command line. ## πŸ“¦ Installation @@ -16,16 +16,18 @@ npm install @playword/cli --save-dev # Use npx to run the package directly (recommended) npx @playword/cli test --headed --verbose ``` -## πŸ’‘ Usage -### Test command +## πŸ“– Available Commands + +### `test` + +Use this command to run a PlayWord test step by step. ```bash -# Run a PlayWord test with options npx @playword/cli test [options] ``` -### Options for test command +### Options for `test` command | Property | Alias | Type | Default | Description | | ------------------ | ----- | -------------- | ---------- | ------------------------------------------------------------------------------------------------------------------ | @@ -36,4 +38,5 @@ npx @playword/cli test [options] | `--use-screenshot` | `-s` | bool | **false** | Whether to enable screenshot reference. | | `--browser` | `-b` | string | **chrome** | Which browser to use. Supported values are `chromium`, `chrome`, `msedge`, `firefox` and `webkit`. | | `--verbose` | `-v` | bool | **false** | Whether to enable verbose mode. | -| `--openai-options` | `-o` | array | **[]** | Additional OpenAI API options. e.g.
`npx @playword/cli test --openai-options apiKey=sk-... baseURL=https://...` | +| `--openai-options` | `-o` | array | **[]** | Additional OpenAI API options. e.g.
`--openai-option apiKey=sk-... baseURL=https://...` | +| `--help` | | bool | **false** | Show help information. | diff --git a/packages/cli/src/testCommand.ts b/packages/cli/src/testCommand.ts index 6a21c06..bfa16ce 100644 --- a/packages/cli/src/testCommand.ts +++ b/packages/cli/src/testCommand.ts @@ -17,7 +17,7 @@ export default { return yargs .option('headed', { alias: 'h', - describe: 'Whether to enable headed mode' + describe: 'Whether to open the browser in headed mode' }) .option('env-file', { alias: 'e', @@ -29,7 +29,7 @@ export default { }) .option('playback', { alias: 'p', - describe: 'Playback the specified recording file. Should be used with --record.' + describe: 'Whether to playback the test steps from a recording file' }) .option('use-screenshot', { alias: 's', @@ -47,7 +47,7 @@ export default { }) .option('openai-options', { alias: 'o', - describe: 'Options to pass to OpenAI API', + describe: 'Additional OpenAI API options', type: 'array', coerce: (options: string[]) => options.reduce( @@ -97,13 +97,13 @@ export default { if (recordings.length && argv.playback) for (const rec of recordings) await runPlayWord(playword, rec.input) else - do await runPlayWord(playword, '[AI] ' + (await input({ message: 'What do you want to do?' }))) + do await runPlayWord(playword, await input({ message: 'What do you want to do?' })) while (await confirm({ message: 'Continue to next step?' })) info('Closing browser') await browser.close() - if (argv.record) info('Recordings: ' + record) + if (argv.record) info('Saved recordings to ' + record) info('Test completed', 'green') process.exit(0) diff --git a/packages/core/README.md b/packages/core/README.md index 37fd277..9993cb8 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -30,10 +30,10 @@ For ease of use, I recommend running this package with `npx`. ```bash # Run a PlayWord test step by step -npx @playword/cli test --headed --verbose +npx @playword/cli test --headed --verbose -b webkit ``` -[See documentation](https://github.com/Foreverskyin0216/playword/tree/main/packages/cli) for usage example and options documentation. +See [documentation](https://github.com/Foreverskyin0216/playword/tree/main/packages/cli) for usage examples and options. ## πŸ“˜ Getting Started @@ -56,7 +56,7 @@ const playword = new PlayWord(page, { }) ``` -## πŸ’¬ Communicate with the browser +## πŸ’¬ Communicate with Browser In its basic usage, you can initialize PlayWord with a Playwright page and use the `say` method to interact with the page. @@ -64,7 +64,7 @@ In its basic usage, you can initialize PlayWord with a Playwright page and use t No need to worry about locating elements or performing interactionsβ€”β€”**PlayWord handles all of that for you**. -### βœ… assertion +### βœ… Assertion In PlayWord, keywords are used to identify whether a step is an assertion. This approach ensures more stable results compared to relying solely on AI judgment. @@ -116,7 +116,7 @@ A sentence starting with any of the following **case-insensitive** keywords will - validate - verify -### πŸ–ΌοΈ Frame handling +### πŸ–ΌοΈ Frame Handling To interact with elements inside frames, simply instruct PlayWord to switch to the desired frame. @@ -133,7 +133,7 @@ await playword.say('Switch to the frame with the url "https://www.saucedemo.com" await playword.say('Switch to the main frame') ``` -### πŸ”§ Custom variables +### πŸ”§ Custom Variables Hardcoding sensitive information in your test cases is not a good practice. Instead, use custom variables with the syntax `{VARIABLE_NAME}` and define them in your environment settings. @@ -169,7 +169,7 @@ const playword = new PlayWord(page, { record: 'path/to/recordings.json' }) When recordings are available, PlayWord will prioritize using them to execute tests, eliminating the need to consume API tokens. -### πŸ”„ Retry on failure +### πŸ”„ Retry on Failure Occasionally, errors may occur due to UI changes or unexpected behaviors. In such cases, enabling `retryOnFailure` allows PlayWord to retry the failed action using AI, increasing test resilience. @@ -178,7 +178,7 @@ In such cases, enabling `retryOnFailure` allows PlayWord to retry the failed act const playword = new PlayWord(page, { record: true, retryOnFailure: true }) ``` -### ✨ Force AI Control +### ✨ Using AI during Playback To force PlayWord to use AI for specific steps during playback, start the sentence with `[AI]`. @@ -188,7 +188,7 @@ await playword.say('[AI] click the "Login" button') await playword.say('[AI] verify the URL matches "https://www.saucedemo.com/inventory.html"') ``` -## πŸ“Έ Screenshot reference +## πŸ“Έ Screenshot Reference Screenshot reference helps AI understand the page state and better meet your needs. @@ -209,9 +209,9 @@ const playword = new PlayWord(page, { useScreenshot: true }) | Maintainance | High maintenance cost due to UI changes | AI-powered adaption to UI changes | | Learning Curve | Requires knowledge of testing frameworks and tools | Just use natural language to execute tests | -## πŸ“œ Supported actions in PlayWord +## πŸ“œ Supported Actions in PlayWord -### Page actions +### Page Actions - Click on an element - Get a specific attribute from an element @@ -240,6 +240,8 @@ const playword = new PlayWord(page, { useScreenshot: true }) - Check if the page URL matches specific RegExp patterns - Check if the screenshot of an element contains specific information ✨ -### Note: The actions marked with ✨ are AI-powered even during playback. +**Note**: The actions marked with ✨ are AI-powered even during playback. -## πŸš€ More actions will be supported in future releases +### More actions will be supported in future releases πŸš€ + +## Finally, Have Fun with PlayWord! πŸŽ‰ diff --git a/packages/core/package.json b/packages/core/package.json index c8250f7..bb5a70c 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@playword/core", "version": "0.1.1", - "description": "Turn your ideas into executable browser actions, bringing a new way to test your web applications.", + "description": "Turn your ideas into actions on the page, bringing a new way to test your web applications.", "keywords": [ "ai", "automated test",