Skip to content

Commit fd44d63

Browse files
authored
feat: add docstrings and doc files (#63)
1 parent 9266137 commit fd44d63

File tree

7 files changed

+93
-18
lines changed

7 files changed

+93
-18
lines changed

README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ export default defineConfig({
2424
name: "android",
2525
use: {
2626
platform: Platform.ANDROID,
27-
deviceName: "Google Pixel 8",
28-
osVersion: "14.0",
29-
buildURL: process.env.BROWSERSTACK_APP_URL,
27+
device: {
28+
provider: "emulator",
29+
name: "Google Pixel 8",
30+
osVersion: "14.0",
31+
}
32+
buildPath: "app-release.apk",
3033
},
3134
},
3235
],
@@ -42,16 +45,7 @@ npx appwright test --project android
4245
npx appwright test --project ios
4346
```
4447

45-
These environment variables are required:
48+
## Docs
4649

47-
- BROWSERSTACK_USERNAME
48-
- BROWSERSTACK_ACCESS_KEY
49-
- BROWSERSTACK_APP_URL
50-
51-
## Development
52-
53-
### Install dependencies
54-
55-
```bash
56-
npm install
57-
```
50+
- [Configuration](docs/config.md)
51+
- [Locators](docs/locators.md)

docs/assertions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Assertions
2+
- await expect().toBeVisible()

docs/basics.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- Basics
2+
- Write a test: Built-in fixtures (client)
3+
- Run the test
4+
- See report

docs/config.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Configuration
2+
3+
- Configuration
4+
- Choose which devices to test and device provider (local or BrowserStack)
5+
6+
## Device Providers
7+
8+
Device providers make Appium compatible mobile devices available to Appwright. These
9+
providers are supported:
10+
11+
- `local-device`
12+
- `emulator`
13+
- `browserstack`
14+
15+
### BrowserStack
16+
17+
BrowserStack [App Automate](https://www.browserstack.com/app-automate) can be used to provide
18+
remote devices to Appwright.
19+
20+
These environment variables are required for the BrowserStack
21+
22+
- BROWSERSTACK_USERNAME
23+
- BROWSERSTACK_ACCESS_KEY

docs/locators.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- Locators
2+
- How to select an element
3+
- These actions are on `client`
4+
- How to take actions on the element

docs/reference.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- API reference
2+
- Driver -> get locators
3+
- Locator -> actions

src/types/index.ts

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,80 @@ export enum Platform {
3737
}
3838

3939
export interface IDevice {
40+
/**
41+
* Helper method to identify which the mobile OS running on the device.
42+
* @returns "android" or "ios"
43+
*/
44+
getPlatform: () => Platform;
45+
46+
/**
47+
* Closes the automation session. This is called automatically after each test.
48+
*/
4049
close: () => Promise<void>;
4150

51+
/**
52+
* Tap on the screen at the given coordinates, specified as x and y. The top left corner
53+
* of the screen is { x: 0, y: 0 }.
54+
*
55+
* @param coordinates to tap on
56+
* @returns
57+
*/
4258
tap: ({ x, y }: { x: number; y: number }) => Promise<void>;
4359

60+
/**
61+
* Locate an element on the screen with text content. This method defaults to a
62+
* substring match, and this be overridden by setting the `exact` option to `true`.
63+
*
64+
* **Usage:**
65+
* ```js
66+
* // with string
67+
* const submitButton = device.getByText("Submit");
68+
*
69+
* // with RegExp
70+
* const counter = device.getByText(/^Counter: \d+/);
71+
* ```
72+
*
73+
* @param text string or regular expression to search for
74+
* @param options
75+
* @returns
76+
*/
4477
getByText: (
4578
text: string | RegExp,
4679
options?: { exact?: boolean },
4780
) => AppwrightLocator;
4881

82+
/**
83+
* Locate an element on the screen with accessibility identifier. This method defaults to
84+
* a substring match, and this can be overridden by setting the `exact` option to `true`.
85+
*
86+
* @param text string or regular expression to search for
87+
* @param options
88+
* @returns
89+
*/
4990
getById: (
5091
text: string | RegExp,
5192
options?: { exact?: boolean },
5293
) => AppwrightLocator;
5394

5495
getByXpath: (xpath: string) => AppwrightLocator;
5596

97+
/**
98+
* Retrieves text content from the clipboard of the mobile device. This is useful
99+
* after a "copy to clipboard" action has been performed.
100+
*
101+
* @returns Returns the text content of the clipboard.
102+
*/
56103
getClipboardText: () => Promise<string>;
57104

58105
beta: {
59106
tap: (prompt: string) => Promise<void>;
60107
extractText: (prompt: string) => Promise<string>;
61108
};
62-
63-
getPlatform: () => Platform;
64109
}
65110

66111
export interface AppwrightLocator {
67112
/**
68-
* Clicks (taps) on the element. This method waits for the element to be visible before clicking it.
113+
* Taps (clicks) on the element. This method waits for the element to be visible before clicking it.
69114
*
70115
* **Usage:**
71116
* ```js

0 commit comments

Comments
 (0)