Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ on:
pull_request:
branches: [master]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
runs-on: self-hosted-arc

strategy:
matrix:
Expand All @@ -29,7 +33,7 @@ jobs:
- run: npm test

deploy-static:
runs-on: ubuntu-latest
runs-on: self-hosted-arc
environment: CI

strategy:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ permissions:
jobs:
# Build job
build:
runs-on: ubuntu-latest
runs-on: self-hosted-arc
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -40,7 +40,7 @@ jobs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
runs-on: self-hosted-arc
needs: build
steps:
- name: Deploy to GitHub Pages
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/how-to-check-accessibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To obtain such a tree, _puppeteer_ has a special [Accessibility class][puppeteer
Here's an example of how to use it:

```javascript
it("should get accessibility tree of yandex.ru", async function ({browser}) {
it("should get accessibility tree of yandex.ru", async function ({ browser }) {
// Get puppeteer instance
const puppeteer = await browser.getPuppeteer();

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/how-to-hide-scrollbars-by-cdp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CDP has a special method [Emulation.setScrollbarsHidden][set-scrollbars-hidden]
Here's how it looks:

```javascript
it("should hide scrollbar", async function ({browser}) {
it("should hide scrollbar", async function ({ browser }) {
// Get puppeteer instance
const puppeteer = await browser.getPuppeteer();

Expand Down
26 changes: 13 additions & 13 deletions docs/guides/how-to-intercept-requests-and-responses.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Let's try writing tests using this API and cover different cases. To clarify, al
## Example 1: Mocking a Request to google.com and Returning Our Own Response {#example_1}

```javascript
it("should mock google.com", async function ({browser}) {
it("should mock google.com", async function ({ browser }) {
// Mocking the request to google.com
const mock = await browser.mock("https://google.com");

Expand All @@ -46,7 +46,7 @@ it("should mock google.com", async function ({browser}) {
From the graphical representation, you can see that we returned our text, although the browser's address bar shows we navigated to _google.com._ Also, it's clear that we didn't mock the favicon, which was fetched from an external source. We can write this same example using the puppeteer API. For this, _webdriverio_ has the [getPuppeteer()][get-puppeteer] command:

```javascript
it("should mock google.com using puppeteer api", async function ({browser}) {
it("should mock google.com using puppeteer api", async function ({ browser }) {
// Get puppeteer instance
const puppeteer = await browser.getPuppeteer();

Expand Down Expand Up @@ -78,7 +78,7 @@ it("should mock google.com using puppeteer api", async function ({browser}) {
Now, let's imagine that puppeteer doesn't yet have an API for mocking requests, but this is already implemented in the [Fetch][fetch] domain of CDP. In this case, we will use this domain's method by interacting with the CDP session directly. For this, puppeteer has the [CDPSession.send()][cdp-session-send] method:

```javascript
it("should mock google.com using cdp fetch domain", async function ({browser}) {
it("should mock google.com using cdp fetch domain", async function ({ browser }) {
// Get puppeteer instance
const puppeteer = await browser.getPuppeteer();

Expand Down Expand Up @@ -122,7 +122,7 @@ Obviously, when using the _webdriverio_ API for mocking requests, the code is mu
## Example 2: Canceling the Request for Google's Logo {#example_2}

```javascript
it("should abort request to logo on google.com", async function ({browser}) {
it("should abort request to logo on google.com", async function ({ browser }) {
// You can use a mask for the URL
const mock = await browser.mock("https://www.google.com/images/**/*.png");

Expand All @@ -138,7 +138,7 @@ From the graphical representation, it is clear that the logo is not displayed, a
## Example 3: Loading google.com Using a Fixture for the Response {#example_3}

```javascript
it("should mock google.com and return answer from fixture", async function ({browser}) {
it("should mock google.com and return answer from fixture", async function ({ browser }) {
// Mocking the request to google.com
const mock = await browser.mock("https://google.com");

Expand All @@ -155,7 +155,7 @@ From the graphical representation, it is clear that instead of google.com's cont
## Example 4: Redirecting the Request from google.com to yandex.ru {#example_4}

```javascript
it("should redirect from google.com to yandex.ru", async function ({browser}) {
it("should redirect from google.com to yandex.ru", async function ({ browser }) {
// Mocking the request to google.com
const mock = await browser.mock("https://google.com");

Expand All @@ -173,7 +173,7 @@ Puppeteer still does not have an API for conveniently modifying responses. There
Replace all occurrences of the string `Google` with `Yandex` in google.com's response:

```javascript
it("should modify response from google.com", async function ({browser}) {
it("should modify response from google.com", async function ({ browser }) {
// Here, you need to mock with www because navigating to google.com
// returns a 301 response without a body and redirects to www
const mock = await browser.mock("https://www.google.com");
Expand All @@ -190,7 +190,7 @@ it("should modify response from google.com", async function ({browser}) {
Additionally, we can modify responses from unknown sources in advance. For example, let's modify all scripts loaded on _google.com:_

```javascript
it("should modify response from google.com", async function ({browser}) {
it("should modify response from google.com", async function ({ browser }) {
// The first argument specifies that we will intercept all requests
const mock = await browser.mock("**", {
headers: headers => {
Expand All @@ -217,7 +217,7 @@ it("should modify response from google.com", async function ({browser}) {
Let's say we need to collect a list of all URLs loaded on the page. Using this information, we could determine if we have requests for external resources or neighboring services that we do not control. This means they could fail at any time and break our tests. Here's what our code might look like:

```javascript
it("should mock yandex.ru and log all loaded urls", async function ({browser}) {
it("should mock yandex.ru and log all loaded urls", async function ({ browser }) {
// Intercept absolutely all requests
const mock = await browser.mock("**");

Expand All @@ -235,7 +235,7 @@ it("should mock yandex.ru and log all loaded urls", async function ({browser}) {
Most likely, your tests are more complex than these examples and involve various clicks on elements that open in new tabs. In such cases, the previous code will not capture the opening of new tabs or that URLs need to be collected there as well. Therefore, in such cases, you need to use puppeteer's API:

```javascript
it("should mock yandex.ru and log all loaded urls (using puppeteer)", async function ({browser}) {
it("should mock yandex.ru and log all loaded urls (using puppeteer)", async function ({ browser }) {
// Accumulative list of all URLs
const urls = [];

Expand Down Expand Up @@ -298,7 +298,7 @@ module.exports = {
"testplane-global-hook": {
enabled: true,

beforeEach: async function ({browser}) {
beforeEach: async function ({ browser }) {
// Check that the browser name starts with "chrome"
if (!/^chrome$/i.test(browser.capabilities.browserName)) {
return;
Expand All @@ -309,7 +309,7 @@ module.exports = {
mock.respond("hello world", { fetchResponse: false });
},

afterEach: function ({browser}) {
afterEach: function ({ browser }) {
// Clear all mocks in the current session
browser.mockRestoreAll();
},
Expand All @@ -327,7 +327,7 @@ The test code will now only contain the URL transition:
```javascript
// Explicitly indicate that the test is only executed in browsers whose name starts with chrome
testplane.only.in(/^chrome/);
it("should mock google.com inside global before each", async function ({browser}) {
it("should mock google.com inside global before each", async function ({ browser }) {
await browser.url("https://google.com");
});
```
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/how-to-manage-cpu-performance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The CPU speed on mobile devices is significantly slower than on computers. There
Let's use this method to slow down CPU speed by 8 times:

```javascript
it("should open yandex.ru with emulation 8x slower CPU", async function ({browser}) {
it("should open yandex.ru with emulation 8x slower CPU", async function ({ browser }) {
// Get puppeteer instance
const puppeteer = await browser.getPuppeteer();

Expand All @@ -39,7 +39,7 @@ Initially, _webdriverio_ did not support the `page.emulateCPUThrottling` method
However, this limitation could be bypassed using puppeteer's [CDPSession.send()][cdp-session-send] method by sending the browser the [Emulation.setCPUThrottlingRate][emulation-set-cpu-throttling-rate] command via CDP:

```javascript
it("should open yandex.ru with emulation 8x slower CPU", async function ({browser}) {
it("should open yandex.ru with emulation 8x slower CPU", async function ({ browser }) {
// Get puppeteer instance
const puppeteer = await browser.getPuppeteer();

Expand Down
4 changes: 2 additions & 2 deletions docs/guides/how-to-manage-network-bandwidth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Besides custom settings, the [throttle][throttle] method supports the following
Let's emulate a 2G connection and open yandex.ru in Chrome with phone emulation:

```javascript
it("should open yandex.ru with emulation of 2G-connection", async function ({browser}) {
it("should open yandex.ru with emulation of 2G-connection", async function ({ browser }) {
// Emulate a 2G connection
await browser.throttle("Good2G");

Expand All @@ -41,7 +41,7 @@ it("should open yandex.ru with emulation of 2G-connection", async function ({bro
We can also emulate a connection with specific characteristics:

```javascript
it("should open yandex.ru with emulation of custom connection", async function ({browser}) {
it("should open yandex.ru with emulation of custom connection", async function ({ browser }) {
// Emulate a network connection with specified characteristics
await browser.throttle({
offline: false, // emulate offline state
Expand Down
4 changes: 2 additions & 2 deletions docs/plugins/testplane-global-hook.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ Add the plugin to the `plugins` section of the `testplane` config:
module.exports = {
plugins: {
"testplane-global-hook": {
beforeEach: async function ({browser}) {
beforeEach: async function ({ browser }) {
await browser.deleteCookie(); // Say, we want to always clear cookies before running a test
},
afterEach: async function ({browser}) {
afterEach: async function ({ browser }) {
await browser.execute(function () {
try {
localStorage.clear(); // And always clean up the localStorage after the test is completed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Admonition from "@theme/Admonition";
Вот пример, как его можно использовать:

```javascript
it("should get accessibility tree of yandex.ru", async function ({browser}) {
it("should get accessibility tree of yandex.ru", async function ({ browser }) {
// Получаем инстанс puppeteer'а
const puppeteer = await browser.getPuppeteer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Admonition from "@theme/Admonition";
Вот как это будет выглядеть:

```javascript
it("should hide scrollbar", async function ({browser}) {
it("should hide scrollbar", async function ({ browser }) {
// Получаем инстанс puppeteer'а
const puppeteer = await browser.getPuppeteer();

Expand Down
Loading