Skip to content

Commit

Permalink
Merge pull request #16 from Foreverskyin0216/chore-adjust-wording-style
Browse files Browse the repository at this point in the history
chore: adjust the wording style
  • Loading branch information
Foreverskyin0216 authored Dec 12, 2024
2 parents 9aed9c0 + c482680 commit 6969ef0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
15 changes: 9 additions & 6 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 |
| ------------------ | ----- | -------------- | ---------- | ------------------------------------------------------------------------------------------------------------------ |
Expand All @@ -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.<br>`npx @playword/cli test --openai-options apiKey=sk-... baseURL=https://...` |
| `--openai-options` | `-o` | array | **[]** | Additional OpenAI API options. e.g.<br>`--openai-option apiKey=sk-... baseURL=https://...` |
| `--help` | | bool | **false** | Show help information. |
10 changes: 5 additions & 5 deletions packages/cli/src/testCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
28 changes: 15 additions & 13 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -56,15 +56,15 @@ 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.

![PlayWord](https://i.ibb.co/dpGSFgG/demo3.gif)

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.

Expand Down Expand Up @@ -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.

Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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]`.

Expand All @@ -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.

Expand All @@ -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
Expand Down Expand Up @@ -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! 🎉
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 6969ef0

Please sign in to comment.