Skip to content

Commit

Permalink
Merge branch '3.x' into fix-recording-network
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent authored Aug 1, 2023
2 parents e0229e6 + e8b7333 commit 683120f
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 26 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,7 @@ Thanks all to those who are and will have contributing to this awesome project!
<a href="https://github.com/pablopaul"><img src="https://avatars.githubusercontent.com/u/635526?v=4" title="pablopaul" width="80" height="80"></a>
<a href="https://github.com/Georgegriff"><img src="https://avatars.githubusercontent.com/u/9056958?v=4" title="Georgegriff" width="80" height="80"></a>
<a href="https://github.com/mirao"><img src="https://avatars.githubusercontent.com/u/12584138?v=4" title="mirao" width="80" height="80"></a>
<a href="https://github.com/actions-user"><img src="https://avatars.githubusercontent.com/u/65916846?v=4" title="actions-user" width="80" height="80"></a>
<a href="https://github.com/KMKoushik"><img src="https://avatars.githubusercontent.com/u/24666922?v=4" title="KMKoushik" width="80" height="80"></a>
<a href="https://github.com/apps/dependabot"><img src="https://avatars.githubusercontent.com/in/29110?v=4" title="dependabot[bot]" width="80" height="80"></a>
<a href="https://github.com/nikocanvacom"><img src="https://avatars.githubusercontent.com/u/83254493?v=4" title="nikocanvacom" width="80" height="80"></a>
<a href="https://github.com/elukoyanov"><img src="https://avatars.githubusercontent.com/u/11647141?v=4" title="elukoyanov" width="80" height="80"></a>
<a href="https://github.com/gkushang"><img src="https://avatars.githubusercontent.com/u/3663389?v=4" title="gkushang" width="80" height="80"></a>
Expand Down
2 changes: 1 addition & 1 deletion docs/helpers/Playwright.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Type: [object][5]
- `ignoreLog` **[Array][9]&lt;[string][8]>?** An array with console message types that are not logged to debug log. Default value is `['warning', 'log']`. E.g. you can set `[]` to log all messages. See all possible [values][44].
- `ignoreHTTPSErrors` **[boolean][32]?** Allows access to untrustworthy pages, e.g. to a page with an expired certificate. Default value is `false`
- `bypassCSP` **[boolean][32]?** bypass Content Security Policy or CSP
- `highlightElement` **[boolean][32]?** highlight the interacting elements
- `highlightElement` **[boolean][32]?** highlight the interacting elements. Default: false



Expand Down
2 changes: 1 addition & 1 deletion docs/helpers/Puppeteer.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Type: [object][4]
- `manualStart` **[boolean][20]?** do not start browser before a test, start it manually inside a helper with `this.helpers["Puppeteer"]._startBrowser()`.
- `browser` **[string][6]?** can be changed to `firefox` when using [puppeteer-firefox][2].
- `chrome` **[object][4]?** pass additional [Puppeteer run options][25].
- `highlightElement` **[boolean][20]?** highlight the interacting elements
- `highlightElement` **[boolean][20]?** highlight the interacting elements. Default: false



Expand Down
2 changes: 1 addition & 1 deletion docs/helpers/WebDriver.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Type: [object][16]
- `desiredCapabilities` **[object][16]?** Selenium's [desired capabilities][6].
- `manualStart` **[boolean][32]?** do not start browser before a test, start it manually inside a helper with `this.helpers["WebDriver"]._startBrowser()`.
- `timeouts` **[object][16]?** [WebDriver timeouts][37] defined as hash.
- `highlightElement` **[boolean][32]?** highlight the interacting elements
- `highlightElement` **[boolean][32]?** highlight the interacting elements. Default: false



Expand Down
7 changes: 4 additions & 3 deletions lib/helper/Playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const pathSeparator = path.sep;
* @prop {string[]} [ignoreLog] - An array with console message types that are not logged to debug log. Default value is `['warning', 'log']`. E.g. you can set `[]` to log all messages. See all possible [values](https://playwright.dev/docs/api/class-consolemessage#console-message-type).
* @prop {boolean} [ignoreHTTPSErrors] - Allows access to untrustworthy pages, e.g. to a page with an expired certificate. Default value is `false`
* @prop {boolean} [bypassCSP] - bypass Content Security Policy or CSP
* @prop {boolean} [highlightElement] - highlight the interacting elements
* @prop {boolean} [highlightElement] - highlight the interacting elements. Default: false
*/
const config = {};

Expand Down Expand Up @@ -343,7 +343,8 @@ class Playwright extends Helper {
show: false,
defaultPopupAction: 'accept',
use: { actionTimeout: 0 },
ignoreHTTPSErrors: false, // Adding it here o that context can be set up to ignore the SSL errors
ignoreHTTPSErrors: false, // Adding it here o that context can be set up to ignore the SSL errors,
highlightElement: false,
};

config = Object.assign(defaults, config);
Expand Down Expand Up @@ -3519,7 +3520,7 @@ async function saveTraceForContext(context, name) {
}

function highlightActiveElement(element, context) {
if (!this.options.enableHighlight && !store.debugMode) return;
if (!this.options.highlightElement && !store.debugMode) return;

highlightElement(element, context);
}
Expand Down
5 changes: 3 additions & 2 deletions lib/helper/Puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const consoleLogStore = new Console();
* @prop {boolean} [manualStart=false] - do not start browser before a test, start it manually inside a helper with `this.helpers["Puppeteer"]._startBrowser()`.
* @prop {string} [browser=chrome] - can be changed to `firefox` when using [puppeteer-firefox](https://codecept.io/helpers/Puppeteer-firefox).
* @prop {object} [chrome] - pass additional [Puppeteer run options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
* @prop {boolean} [highlightElement] - highlight the interacting elements
* @prop {boolean} [highlightElement] - highlight the interacting elements. Default: false
*/
const config = {};

Expand Down Expand Up @@ -231,6 +231,7 @@ class Puppeteer extends Helper {
keepBrowserState: false,
show: false,
defaultPopupAction: 'accept',
highlightElement: false,
};

return Object.assign(defaults, config);
Expand Down Expand Up @@ -2714,7 +2715,7 @@ function getNormalizedKey(key) {
}

function highlightActiveElement(element, context) {
if (!this.options.enableHighlight && !store.debugMode) return;
if (!this.options.highlightElement && !store.debugMode) return;

highlightElement(element, context);
}
5 changes: 3 additions & 2 deletions lib/helper/WebDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const webRoot = 'body';
* @prop {object} [desiredCapabilities] Selenium's [desired capabilities](https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities).
* @prop {boolean} [manualStart=false] - do not start browser before a test, start it manually inside a helper with `this.helpers["WebDriver"]._startBrowser()`.
* @prop {object} [timeouts] [WebDriver timeouts](http://webdriver.io/docs/timeouts.html) defined as hash.
* @prop {boolean} [highlightElement] - highlight the interacting elements
* @prop {boolean} [highlightElement] - highlight the interacting elements. Default: false
*/
const config = {};

Expand Down Expand Up @@ -429,6 +429,7 @@ class WebDriver extends Helper {
keepCookies: false,
keepBrowserState: false,
deprecationWarnings: false,
highlightElement: false,
};

// override defaults with config
Expand Down Expand Up @@ -2914,7 +2915,7 @@ function isModifierKey(key) {
}

function highlightActiveElement(element) {
if (!this.options.enableHighlight && !store.debugMode) return;
if (!this.options.highlightElement && !store.debugMode) return;

highlightElement(element, this.browser);
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"def": "./runok.js def",
"dev:graphql": "node test/data/graphql/index.js",
"publish:site": "./runok.js publish:site",
"update-contributor-faces": "contributor-faces .",
"update-contributor-faces": "./runok.js contributor:faces",
"dtslint": "dtslint typings --localTs './node_modules/typescript/lib'",
"prepare": "husky install"
},
Expand Down Expand Up @@ -104,8 +104,8 @@
"@faker-js/faker": "^7.6.0",
"@pollyjs/adapter-puppeteer": "^6.0.5",
"@pollyjs/core": "^5.1.0",
"@types/inquirer": "^0.0.35",
"@types/node": "^8.10.66",
"@types/inquirer": "^9.0.3",
"@types/node": "^20.4.4",
"@wdio/sauce-service": "^8.3.8",
"@wdio/selenium-standalone-service": "^8.3.2",
"@wdio/utils": "^8.3.0",
Expand Down Expand Up @@ -135,7 +135,7 @@
"runok": "^0.9.2",
"sinon": "^15.2.0",
"sinon-chai": "^3.7.0",
"testcafe": "^2.1.0",
"testcafe": "^3.0.1",
"ts-morph": "^3.1.3",
"ts-node": "^10.9.1",
"tsd-jsdoc": "^2.5.0",
Expand Down
10 changes: 10 additions & 0 deletions runok.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
git, copy, exec, replaceInFile, npmRun, npx, writeToFile,
}, runok,
} = require('runok');
const contributors = require('contributor-faces');

const helperMarkDownFile = function (name) {
return `docs/helpers/${name}.md`;
Expand Down Expand Up @@ -434,6 +435,15 @@ title: ${name}
const logs = await exec('git log --pretty=\'format:%s - by %aN\' $(git describe --abbrev=0 --tags)..HEAD');
console.log(logs.data.stdout);
},

async contributorFaces() {
// update contributors list in readme
await contributors.update(null, { exclude: 'actions-user' });
let readmeContent = fs.readFileSync('README.md');
readmeContent = readmeContent.toString()
.replace('<a href="https://github.com/apps/dependabot"><img src="https://avatars.githubusercontent.com/in/29110?v=4" title="dependabot[bot]" width="80" height="80"></a>\n', '');
fs.writeFileSync('./README.md', readmeContent);
},
};

async function processChangelog() {
Expand Down
31 changes: 21 additions & 10 deletions test/helper/Playwright_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,16 +895,27 @@ describe('Playwright', function () {
});

it('should check traffics with more advanced params', async () => {
I.amOnPage('https://openai.com/blog/chatgpt');
I.startRecordingTraffic();
await I.seeTraffic({
name: 'sentry event',
url: 'https://images.openai.com/blob/cf717bdb-0c8c-428a-b82b-3c3add87a600',
parameters: {
width: '1919',
height: '1138',
},
});
await I.startRecordingTraffic();
await I.amOnPage('https://openai.com/blog/chatgpt');
const traffics = await I.grabRecordedNetworkTraffics();

for (const traffic of traffics) {
if (traffic.url.includes('&width=')) {
// new URL object
const currentUrl = new URL(traffic.url);

// get access to URLSearchParams object
const searchParams = currentUrl.searchParams;

await I.seeTraffic({
name: 'sentry event',
url: currentUrl.origin + currentUrl.pathname,
parameters: searchParams,
});

break;
}
}
});

it('should check traffics with more advanced post data', async () => {
Expand Down

0 comments on commit 683120f

Please sign in to comment.