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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
gridUrl: "local",
baseUrl: "http://localhost",
automationProtocol: "devtools",
automationProtocol: "webdriver",
sessionsPerBrowser: 1,
testsPerSession: 10,
windowSize: "1280x720",
Expand Down
75 changes: 65 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"@jspm/core": "2.0.1",
"@jsquash/png": "3.1.1",
"@puppeteer/browsers": "2.7.1",
"@testplane/devtools": "8.32.5",
"@testplane/wdio-protocols": "9.4.7",
"@testplane/wdio-utils": "9.5.4",
"@testplane/webdriverio": "9.5.23",
Expand Down
3 changes: 1 addition & 2 deletions src/browser/commands/openAndWait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ const makeOpenAndWaitCommand = (config: BrowserConfig, session: WebdriverIO.Brow
): Promise<string | void> {
const PageLoader = await import("../../utils/page-loader").then(m => m.default);
const isChrome = config.desiredCapabilities?.browserName === "chrome";
const isCDP = config.automationProtocol === "devtools";

waitNetworkIdle &&= isChrome || isCDP;
waitNetworkIdle &&= isChrome;

const originalPageLoadTimeout = config.pageLoadTimeout;
const shouldUpdateTimeout = timeout && timeout !== originalPageLoadTimeout;
Expand Down
9 changes: 4 additions & 5 deletions src/browser/commands/restoreState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import fs from "fs-extra";
import { restoreStorage } from "./restoreStorage";

import type { Browser } from "../../types";
import { DEVTOOLS_PROTOCOL, WEBDRIVER_PROTOCOL } from "../../../constants/config";
import { getOverridesProtocol, getWebdriverFrames, SaveStateData } from "../saveState";
import { isBidiWithIsolation, getWebdriverFrames, SaveStateData } from "../saveState";
import { getActivePuppeteerPage } from "../../existing-browser";
import { Cookie } from "@testplane/wdio-protocols";
import { StateOpts } from "../../../config/types";
Expand Down Expand Up @@ -40,8 +39,8 @@ export default (browser: Browser): void => {
restoreState.cookies = restoreState?.cookies.filter(options.cookieFilter);
}

switch (getOverridesProtocol(browser)) {
case WEBDRIVER_PROTOCOL: {
switch (isBidiWithIsolation(browser)) {
case false: {
await session.switchToParentFrame();

if (restoreState.cookies && options.cookies) {
Expand Down Expand Up @@ -105,7 +104,7 @@ export default (browser: Browser): void => {

break;
}
case DEVTOOLS_PROTOCOL: {
case true: {
const page = await getActivePuppeteerPage(session);

if (!page) {
Expand Down
17 changes: 6 additions & 11 deletions src/browser/commands/saveState/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import fs from "fs-extra";

import _ from "lodash";
import { dumpStorage, StorageData } from "./dumpStorage";
import { DEVTOOLS_PROTOCOL, WEBDRIVER_PROTOCOL } from "../../../constants/config";
import { ExistingBrowser, getActivePuppeteerPage } from "../../existing-browser";
import * as logger from "../../../utils/logger";
import { Cookie } from "../../../types";
Expand All @@ -18,13 +17,9 @@ export type SaveStateData = {
framesData: Record<string, FrameData>;
};

// in case when we use webdriver protocol, bidi and isolation
// we have to force change protocol to devtools, for use puppeteer,
// because we use it for create incognito window
export const getOverridesProtocol = (browser: Browser): typeof WEBDRIVER_PROTOCOL | typeof DEVTOOLS_PROTOCOL =>
browser.config.automationProtocol === WEBDRIVER_PROTOCOL && browser.publicAPI.isBidi && browser.config.isolation
? DEVTOOLS_PROTOCOL
: browser.config.automationProtocol;
// in case when we use bidi and isolation
// we have to use puppeteer, because we use it for creating incognito window
export const isBidiWithIsolation = (browser: Browser): boolean => browser.publicAPI.isBidi && browser.config.isolation;

export const getWebdriverFrames = async (session: WebdriverIO.Browser): Promise<string[]> =>
session.execute<string[], []>(() =>
Expand All @@ -49,8 +44,8 @@ export default (browser: ExistingBrowser): void => {
framesData: {},
};

switch (getOverridesProtocol(browser)) {
case WEBDRIVER_PROTOCOL: {
switch (isBidiWithIsolation(browser)) {
case false: {
if (options.cookies) {
const cookies = await session.getAllCookies();

Expand Down Expand Up @@ -106,7 +101,7 @@ export default (browser: ExistingBrowser): void => {
data.framesData = framesData;
break;
}
case DEVTOOLS_PROTOCOL: {
case true: {
if (options.cookies) {
const cookies = await session.getAllCookies();

Expand Down
Loading
Loading