-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from amrsa1/parallel-test-pw-ts
Instantiate LT WS connection from config file
- Loading branch information
Showing
4 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "playwright-test-suite", | ||
"version": "1.0.0", | ||
"author": "LambdaTest", | ||
"engines": { | ||
"node": ">=12.0.0" | ||
}, | ||
"description": "Sample project to run playwright tests using playwright runner on LambdaTest platform", | ||
"scripts": { | ||
"test": "npx playwright test --config=./playwright.config.ts" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.24.0", | ||
"playwright": "^1.24.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import type { PlaywrightTestConfig } from "@playwright/test"; | ||
import { devices } from "@playwright/test"; | ||
|
||
const capabilities = [{ | ||
browserName: "Chrome", // Browsers allowed: `Chrome`, `MicrosoftEdge`, `pw-chromium`, `pw-firefox` and `pw-webkit` | ||
browserVersion: "latest", | ||
"LT:Options": { | ||
platform: "Windows 10", | ||
build: "Playwright Build", | ||
name: "Playwright Test", | ||
user: process.env.LT_USERNAME, | ||
accessKey: process.env.LT_ACCESS_KEY, | ||
network: true, | ||
video: true, | ||
console: true, | ||
tunnel: false, // Add tunnel configuration if testing locally hosted webpage | ||
tunnelName: "", // Optional | ||
geoLocation: '', // country code can be fetched from https://www.lambdatest.com/capabilities-generator/ | ||
}, | ||
}, | ||
{ | ||
browserName: "pw-webkit", // Browsers allowed: `Chrome`, `MicrosoftEdge`, `pw-chromium`, `pw-firefox` and `pw-webkit` | ||
browserVersion: "latest", | ||
"LT:Options": { | ||
platform: "MacOS Monterey", | ||
build: "Playwright Build", | ||
name: "Playwright Test", | ||
user: process.env.LT_USERNAME, | ||
accessKey: process.env.LT_ACCESS_KEY, | ||
network: true, | ||
video: true, | ||
console: true, | ||
tunnel: false, // Add tunnel configuration if testing locally hosted webpage | ||
tunnelName: "", // Optional | ||
geoLocation: '', // country code can be fetched from https://www.lambdatest.com/capabilities-generator/ | ||
}, | ||
} | ||
]; | ||
|
||
// Playwright config to run tests on LambdaTest platform and local | ||
const config: PlaywrightTestConfig = { | ||
testDir: "tests", | ||
timeout: 60000, | ||
use: {}, | ||
projects: [ | ||
// -- LambdaTest Config -- | ||
// name in the format: browserName:browserVersion:platform@lambdatest | ||
// Browsers allowed: `Chrome`, `MicrosoftEdge`, `pw-chromium`, `pw-firefox` and `pw-webkit` | ||
// Use additional configuration options provided by Playwright if required: https://playwright.dev/docs/api/class-testconfig | ||
{ | ||
name: "chrome:latest:windows 10@lambdatest", | ||
use: { | ||
connectOptions: { | ||
wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent( | ||
JSON.stringify(capabilities[0]) | ||
)}` | ||
}, | ||
viewport: { width: 1920, height: 1080 }, | ||
}, | ||
}, | ||
{ | ||
name: "safari:latest:macOs Monterey@lambdatest", | ||
use: { | ||
connectOptions: { | ||
wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent( | ||
JSON.stringify(capabilities[1]) | ||
)}` | ||
}, | ||
viewport: { width: 1280, height: 720 }, | ||
}, | ||
}, | ||
{ | ||
name: "safari:latest:macOs Monterey@lambdatest", | ||
use: { | ||
connectOptions: { | ||
wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent( | ||
JSON.stringify(capabilities[1]) | ||
)}` | ||
}, | ||
...devices["iPhone 12 Pro Max"], | ||
}, | ||
} | ||
// Config for running tests in local | ||
// { | ||
// name: "chrome", | ||
// use: { | ||
// browserName: "chromium", | ||
// channel: "chrome", | ||
// }, | ||
// }, | ||
// { | ||
// name: "safari", | ||
// use: { | ||
// browserName: "webkit", | ||
// viewport: { width: 1200, height: 750 }, | ||
// }, | ||
// }, | ||
// { | ||
// name: "firefox", | ||
// use: { | ||
// browserName: "firefox", | ||
// viewport: { width: 800, height: 600 }, | ||
// }, | ||
// }, | ||
// // Test in mobile viewport. | ||
// { | ||
// name: "chrome@pixel5", | ||
// use: { | ||
// ...devices['iPhone 12 Pro Max'], | ||
// } | ||
// }, | ||
], | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import test from "../lambdatest-setup"; | ||
import { expect } from "@playwright/test"; | ||
|
||
test.describe("Browse LambdaTest in different search engines", () => { | ||
test("Search LambdaTest on Bing", async ({ page }) => { | ||
await page.goto("https://www.bing.com"); | ||
const element = await page.$('[aria-label="Enter your search term"]'); | ||
await element.click(); | ||
await element.type("LambdaTest"); | ||
await element.press("Enter"); | ||
const title = await page.title(); | ||
|
||
console.log("Page title:: ", title); | ||
// Use the expect API for assertions provided by playwright | ||
expect(title).toEqual(expect.stringContaining("LambdaTest")); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import test from "../lambdatest-setup"; | ||
import { expect } from "@playwright/test"; | ||
|
||
test.describe("Browse LambdaTest in different search engines", () => { | ||
test("Search LambdaTest Blog on Bing", async ({ page }) => { | ||
await page.goto("https://www.bing.com"); | ||
const element = await page.$('[aria-label="Enter your search term"]'); | ||
await element.click(); | ||
await element.type("LambdaTest Blog"); | ||
await element.press("Enter"); | ||
const title = await page.title(); | ||
|
||
console.log("Page title:: ", title); | ||
// Use the expect API for assertions provided by playwright | ||
expect(title).toEqual(expect.stringContaining("LambdaTest Blog")); | ||
}); | ||
}); |