Skip to content
Open
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
2 changes: 1 addition & 1 deletion packages/drivers/basewebdriver/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import WebTestingFrameworkDriverHelper from "@wix-pilot/web-utils";
import type { ElementMatchingCriteria, Page } from "@wix-pilot/web-utils";
import type {
import {
TestingFrameworkAPICatalog,
TestingFrameworkDriver,
TestingFrameworkDriverConfig,
Expand Down
16 changes: 15 additions & 1 deletion packages/drivers/playwright/examples/example.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,23 @@ describe("Example Test Suite", () => {
pilot.end();
});

it("perform test with pilot", async () => {
it.skip("perform test with pilot", async () => {
await pilot.autopilot(
"Open https://github.com/wix-incubator/pilot and tell me what was the last commit about and who have created it",
);
});

it.skip("open new tab", async () => {
await pilot.perform(
"Open https://wix.github.io/Detox/",
"Tap `#StandWithUkraine` link",
"Tap `Donate to the military`",
);
});

it.only("open new tab", async () => {
await pilot.autopilot(
"Open https://wix.github.io/Detox/ tap `#StandWithUkraine` link. Tap `Donate to the military`",
);
});
});
9 changes: 8 additions & 1 deletion packages/drivers/playwright/frameworkCatalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ export const createAPICatalog: TestingFrameworkAPICatalog = {
timeout: 30000 // Default timeout for all operations
});
const context = await browser.newContext();
//IMPORTANT!
context.on('page', async page => {
await page.waitForLoadState();
await page.bringToFront();
setCurrentPage(page);
});
const page = await context.newPage();
setCurrentPage(page);
await page.goto('https://www.test.com/');
await page.waitForLoadState('load');`,
await page.waitForLoadState('load');
`,
guidelines: [
"Set longer timeouts (30s or more) to handle slow operations.",
"Can use chromium, firefox, or webkit browsers.",
Expand Down
6 changes: 6 additions & 0 deletions packages/drivers/playwright/test-results/.last-run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"status": "failed",
"failedTests": [
"85533e7544b493bab02b-947de5f59fb64680a145"
]
}
16 changes: 15 additions & 1 deletion packages/drivers/puppeteer/examples/example.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe("Example Test Suite", () => {
}),
);

it.only("filter by color", async () => {
it.skip("filter by color", async () => {
await pilot.perform(
"Open https://www.yohaiknaani.com",
"Go to `Shop All` page.",
Expand All @@ -138,4 +138,18 @@ describe("Example Test Suite", () => {
"Tap on the `Submit` button",
);
});

it.only("open new tab", async () => {
await pilot.perform(
"Open https://wix.github.io/Detox/",
"Tap `#StandWithUkraine` link",
"Tap `Donate to the military`",
);
});

it.skip("open new tab", async () => {
await pilot.autopilot(
"Open https://wix.github.io/Detox/ tap `#StandWithUkraine` link. Tap `Donate to the military`",
);
});
});
24 changes: 23 additions & 1 deletion packages/drivers/puppeteer/frameworkCatalog.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { TestingFrameworkAPICatalog } from "@wix-pilot/core";
import * as puppeteer from "puppeteer-core";

const waitForNewTab = () => new Promise((resolve) => setTimeout(resolve, 2000));

export const createAPICatalog = (
executablePath: string,
): TestingFrameworkAPICatalog => ({
Expand All @@ -9,6 +11,7 @@ export const createAPICatalog = (
"Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol.\nYou can assume that puppeteer is already imported (as `puppeteer`).",
context: {
puppeteer,
waitForNewTab,
},
categories: [
{
Expand All @@ -17,12 +20,31 @@ export const createAPICatalog = (
{
signature: "const browser = await puppeteer.launch([options])",
description: "Launches a new browser instance.",
example: `const browser = await puppeteer.launch({ headless: false, executablePath: "${executablePath}" });`,
example: `const browser = await puppeteer.launch({ headless: false, executablePath: "${executablePath}"});

// IMPORTANT!
browser.on('targetcreated', async target => {
if (target.type() === 'page') {
const page = await target.page();
if (page) {
await page.waitForFunction(() => document.readyState === 'complete', {timeout: 5000}).catch(() => {});
await page.bringToFront();
setCurrentPage(page);
}
}
});

const [page] = await browser.pages();
await page.bringToFront();
setCurrentPage(page);
await page.goto('https://www.test.com/', {waitUntil: 'load' });
await this.waitForStableDOM(page);`,
guidelines: [
`Executable path is required always, use the path: ${executablePath}`,
"Options can specify `headless`, `slowMo`, `args`, etc.",
"Prefer passing `headless: false` to `puppeteer.launch()` unless headless mode is explicitly required.",
"Use a large viewport size (e.g. `viewport: { width: 1920, height: 1080 }`) to avoid responsive design issues (for example, use `defaultViewport: null` and `args: ['--start-maximized']`).",
"After clicking any link that opens in a new tab (target='_blank'), always call `await waitForNewTab()` and NOT `await page.waitForNavigation()` to ensure the new tab becomes active before proceeding.",
],
},
{
Expand Down
3 changes: 3 additions & 0 deletions packages/drivers/web-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ export default class WebTestingFrameworkDriverHelper {
"START A NEW ONE BASED ON THE ACTION NEED OR RAISE AN ERROR"
);
}

await new Promise((resolve) => setTimeout(resolve, 700));

await this.waitForStableDOM(this.currentPage);
await this.markImportantElements(this.currentPage);
return await this.createMarkedViewHierarchy(this.currentPage);
Expand Down