You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/get-started/actions/checkLink.md
+85-22Lines changed: 85 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,18 +11,19 @@ description: Check if a URL returns an acceptable status code from a GET request
11
11
12
12
The `checkLink` action checks if a URL returns an acceptable status code from a GET request. This action is useful for verifying that a hyperlink or image URL is valid.
13
13
14
-
You can also specify
14
+
You can specify the target URL directly as a string, or use an object for more options:
15
15
16
-
- an `origin` to navigate to a URL relative to a specific path.
17
-
-`statusCodes` to set acceptable HTTP status codes.
16
+
-`url`: (Required in object format) The URL to check. Can be a full URL or a path. If a path is provided, an `origin` must be specified either in the step or in the configuration file.
17
+
-`origin`: (Optional) Protocol and domain prepended to `url` when `url` is a path. If omitted and `url` is a path, the global `origin` from the configuration file is used.
18
+
-`statusCodes`: (Optional) A single integer or an array of integers representing acceptable HTTP status codes. If omitted, defaults to `[200, 301, 302, 307, 308]`.
18
19
19
20
> For comprehensive options, see the [`checkLink`](/docs/references/schemas/checkLink) reference.
20
21
21
22
## Examples
22
23
23
24
Here are a few ways you might use the `checkLink` action:
24
25
25
-
### Check if a link is valid
26
+
### Check if a link is valid (string shorthand)
26
27
27
28
```json
28
29
{
@@ -31,8 +32,46 @@ Here are a few ways you might use the `checkLink` action:
31
32
"steps": [
32
33
{
33
34
"description": "Check if Google is up.",
34
-
"action": "checkLink",
35
-
"url": "https://www.google.com"
35
+
"checkLink": "https://www.google.com"
36
+
}
37
+
]
38
+
}
39
+
]
40
+
}
41
+
```
42
+
43
+
### Check if a link is valid (object format)
44
+
45
+
```json
46
+
{
47
+
"tests": [
48
+
{
49
+
"steps": [
50
+
{
51
+
"description": "Check if Google is up.",
52
+
"checkLink": {
53
+
"url": "https://www.google.com"
54
+
}
55
+
}
56
+
]
57
+
}
58
+
]
59
+
}
60
+
```
61
+
62
+
### Check for a specific status code response
63
+
64
+
```json
65
+
{
66
+
"tests": [
67
+
{
68
+
"steps": [
69
+
{
70
+
"description": "Check if Google is up, expecting only 200.",
71
+
"checkLink": {
72
+
"url": "https://www.google.com",
73
+
"statusCodes": 200
74
+
}
36
75
}
37
76
]
38
77
}
@@ -49,9 +88,10 @@ Here are a few ways you might use the `checkLink` action:
49
88
"steps": [
50
89
{
51
90
"description": "Check if Google is up with extra status codes.",
52
-
"action": "checkLink",
53
-
"url": "https://www.google.com",
54
-
"statusCodes": [200, 201, 202]
91
+
"checkLink": {
92
+
"url": "https://www.google.com",
93
+
"statusCodes": [200, 201, 202]
94
+
}
55
95
}
56
96
]
57
97
}
@@ -67,10 +107,32 @@ Here are a few ways you might use the `checkLink` action:
67
107
{
68
108
"steps": [
69
109
{
70
-
"description": "Check if Google is up with an origin.",
71
-
"action": "checkLink",
72
-
"url": "/search",
73
-
"origin": "https://www.google.com"
110
+
"description": "Check if Google search path is valid using a specific origin.",
111
+
"checkLink": {
112
+
"url": "/search",
113
+
"origin": "https://www.google.com"
114
+
}
115
+
}
116
+
]
117
+
}
118
+
]
119
+
}
120
+
```
121
+
122
+
### Check a relative link using global origin
123
+
124
+
Assuming a global `origin` of `https://www.google.com` is set in the configuration:
125
+
126
+
```json
127
+
{
128
+
"tests": [
129
+
{
130
+
"steps": [
131
+
{
132
+
"description": "Check if Google search path is valid using global origin.",
133
+
"checkLink": {
134
+
"url": "/search"
135
+
}
74
136
}
75
137
]
76
138
}
@@ -97,9 +159,10 @@ Consider the following test configuration, which checks the validity of `https:/
97
159
"steps": [
98
160
{
99
161
"description": "Check site with a self-signed certificate",
100
-
"action": "checkLink",
101
-
"url": "https://self-signed.badssl.com/",
102
-
"statusCodes": [200, 201, 202, 301]
162
+
"checkLink": {
163
+
"url": "https://self-signed.badssl.com/",
164
+
"statusCodes": [200, 201, 202, 301]
165
+
}
103
166
}
104
167
]
105
168
}
@@ -134,22 +197,22 @@ To fix this issue, follow these steps:
134
197
NODE_TLS_REJECT_UNAUTHORIZED=0
135
198
```
136
199
137
-
2. Modify your test configuration to include a `setVariables`action:
200
+
2. Modify your test configuration to include a `loadVariables` step (Note: `setVariables`is deprecated, use `loadVariables`):
The `click` action allows you to click or tap an element on the page. You can specify which mouse button to use and target elements using text or selectors.
13
+
14
+
The `click` action works in several ways:
15
+
16
+
-**String Shorthand:** The display text or selector of the element to find and click.
17
+
-**Object Format:** Use an object with detailed properties for more control over the click action.
18
+
19
+
If you need to find an element before clicking it, consider using the [`find`](/docs/get-started/actions/find) action, which lets you locate elements and optionally click them in a single step.
20
+
21
+
**Note:** If you use the `click` action without specifying a target (using element text or selector), it will click the active element or the element at the current cursor position.
22
+
23
+
## Properties
24
+
25
+
When using the object format, you can specify:
26
+
27
+
-`button`: (Optional) Kind of click to perform. Can be `"left"`, `"right"`, or `"middle"`. Default is `"left"`.
28
+
-`selector`: (Optional) CSS or XPath selector of the element to click. If combined with `elementText`, the element must match both the text and the selector.
29
+
-`elementText`: (Optional) Display text of the element to click. If combined with `selector`, the element must match both the text and the selector.
30
+
31
+
> For comprehensive options, see the full [`click`](/docs/references/schemas/click) reference.
32
+
33
+
## Examples
34
+
35
+
Here are a few ways you might use the `click` action:
36
+
37
+
### Click by element text (string shorthand)
38
+
39
+
```json
40
+
{
41
+
"tests": [
42
+
{
43
+
"steps": [
44
+
{
45
+
"description": "Click on an element with text 'Submit'",
46
+
"click": "Submit"
47
+
}
48
+
]
49
+
}
50
+
]
51
+
}
52
+
```
53
+
54
+
### Click by selector (string shorthand)
55
+
56
+
```json
57
+
{
58
+
"tests": [
59
+
{
60
+
"steps": [
61
+
{
62
+
"description": "Click on an element matching the CSS selector",
63
+
"click": "#submit-button"
64
+
}
65
+
]
66
+
}
67
+
]
68
+
}
69
+
```
70
+
71
+
### Click an element by text (object format)
72
+
73
+
```json
74
+
{
75
+
"tests": [
76
+
{
77
+
"steps": [
78
+
{
79
+
"description": "Left-click on a button with specific text",
80
+
"click": {
81
+
"elementText": "Submit",
82
+
"button": "left"
83
+
}
84
+
}
85
+
]
86
+
}
87
+
]
88
+
}
89
+
```
90
+
91
+
### Click an element by selector (object format)
92
+
93
+
```json
94
+
{
95
+
"tests": [
96
+
{
97
+
"steps": [
98
+
{
99
+
"description": "Middle-click on an element with a specific selector",
100
+
"click": {
101
+
"selector": "#open-in-new-tab",
102
+
"button": "middle"
103
+
}
104
+
}
105
+
]
106
+
}
107
+
]
108
+
}
109
+
```
110
+
111
+
### Click an element by both selector and text
112
+
113
+
```json
114
+
{
115
+
"tests": [
116
+
{
117
+
"steps": [
118
+
{
119
+
"description": "Click on a specific element matching both selector and text",
120
+
"click": {
121
+
"selector": ".btn",
122
+
"elementText": "Download",
123
+
"button": "left"
124
+
}
125
+
}
126
+
]
127
+
}
128
+
]
129
+
}
130
+
```
131
+
132
+
## Related Actions
133
+
134
+
-[`find`](/docs/get-started/actions/find): Find an element and optionally interact with it
135
+
-[`type`](/docs/get-started/actions/type): Type text or special keys
0 commit comments