testaro 76.1.1 → 76.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/package.json +1 -1
- package/procs/launch.js +26 -5
package/README.md
CHANGED
|
@@ -201,6 +201,8 @@ Here is a sample job, showing properties that you can set:
|
|
|
201
201
|
|
|
202
202
|
The `device` property lets you choose among [about 125 devices recognized by Playwright](https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json).
|
|
203
203
|
|
|
204
|
+
The `browserID` property dictates the first browser type that Testaro uses for its requests. When requests with that browser type are repeatedly rejected, Testaro switches to a different browser type and also replaces the `browserID` property of the job with that new browser type. Targets and their edge-management platforms often block requests from one browser type but not another, so switching browser types can make a job succeed instead of failing or make it finish quickly instead of slowly.
|
|
205
|
+
|
|
204
206
|
The act types and their options are documented in the `etc` property of the [actSpecs.js](actSpecs.js) object and in the [actSpecs-doc.md](actSpecs-doc.md) file.
|
|
205
207
|
|
|
206
208
|
## Running jobs
|
package/package.json
CHANGED
package/procs/launch.js
CHANGED
|
@@ -172,11 +172,26 @@ const goTo = exports.goTo = async (report, page, url, timeout, waitUntil) => {
|
|
|
172
172
|
}
|
|
173
173
|
// Otherwise, if the response status was prohibition:
|
|
174
174
|
else if (httpStatus === 403) {
|
|
175
|
-
//
|
|
175
|
+
// Log this.
|
|
176
176
|
console.log(`ERROR: Visit to ${url} prohibited (status 403)`);
|
|
177
|
+
// Collect diagnostic data from the response.
|
|
178
|
+
let rejectionData = {status: 403};
|
|
179
|
+
try {
|
|
180
|
+
const headers = await response.allHeaders();
|
|
181
|
+
rejectionData.server = headers['server'] || '';
|
|
182
|
+
rejectionData.cfRay = headers['cf-ray'] || '';
|
|
183
|
+
rejectionData.via = headers['via'] || '';
|
|
184
|
+
rejectionData.xAkamai = headers['x-akamai-transformed'] || '';
|
|
185
|
+
rejectionData.xSucuri = headers['x-sucuri-id'] || '';
|
|
186
|
+
rejectionData.xWaf = headers['x-waf-event-info'] || '';
|
|
187
|
+
rejectionData.headers = headers;
|
|
188
|
+
}
|
|
189
|
+
catch {}
|
|
190
|
+
// Return the prohibition and the data.
|
|
177
191
|
return {
|
|
178
192
|
success: false,
|
|
179
|
-
error: 'status403'
|
|
193
|
+
error: 'status403',
|
|
194
|
+
rejectionData
|
|
180
195
|
};
|
|
181
196
|
}
|
|
182
197
|
// Otherwise, if the response status was rejection of excessive requests:
|
|
@@ -340,7 +355,8 @@ const launchOnce = async opts => {
|
|
|
340
355
|
// Create a context (i.e. window) for it.
|
|
341
356
|
const contextOptions = {
|
|
342
357
|
...device.windowOptions,
|
|
343
|
-
userAgent:
|
|
358
|
+
userAgent: device.windowOptions.userAgent
|
|
359
|
+
|| 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36',
|
|
344
360
|
viewport: device.windowOptions.viewport || {width: 1920, height: 1080},
|
|
345
361
|
locale: 'en-US',
|
|
346
362
|
timezoneId: 'America/Los_Angeles',
|
|
@@ -533,8 +549,12 @@ const launchOnce = async opts => {
|
|
|
533
549
|
}
|
|
534
550
|
// Otherwise, i.e. if the navigation failed:
|
|
535
551
|
else {
|
|
552
|
+
const {rejectionData} = navResult;
|
|
553
|
+
const addendum = rejectionData
|
|
554
|
+
? ` (rejection data: ${JSON.stringify(rejectionData, null, 2)})`
|
|
555
|
+
: '';
|
|
536
556
|
// Throw an error.
|
|
537
|
-
throw new Error(`Navigation failed
|
|
557
|
+
throw new Error(`Navigation failed: ${navResult.error}${addendum}`);
|
|
538
558
|
}
|
|
539
559
|
}
|
|
540
560
|
// If the browser and page creation and navigation threw an error:
|
|
@@ -647,7 +667,8 @@ exports.launch = async (opts = {}) => {
|
|
|
647
667
|
if (tempBrowserID && unusedBrowserIDs.length && ! retriesLeft) {
|
|
648
668
|
// Change the browser type.
|
|
649
669
|
tempBrowserID = unusedBrowserIDs.shift();
|
|
650
|
-
console.log(`NOTICE: Changing browser type to ${tempBrowserID}`);
|
|
670
|
+
console.log(`NOTICE: Changing job browser type to ${tempBrowserID}`);
|
|
671
|
+
report.browserID = tempBrowserID;
|
|
651
672
|
// Reset the retries.
|
|
652
673
|
retriesLeft = retries;
|
|
653
674
|
}
|