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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion docs/biometric-authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ Below given is the list of Biometric Authentication APIs which are supported. Pl
|`canEvaluatePolicy`: The canEvaluatePolicy(_:error:) method of LAContext that checks whether a specific biometric authentication policy can be evaluated on the device.|
</div>

:::warning note
We don’t support apps using IOS Keychain APIs with Biometric access control. For more details [IOS Keychain Documentation](https://developer.apple.com/documentation/localauthentication/accessing-keychain-items-with-face-id-or-touch-id)
:::

</TabItem>

<TabItem value="powershell" label="Android >= version 11" default>
Expand All @@ -83,12 +87,14 @@ Below given is the list of Biometric Authentication APIs which are supported. Pl
|----------------|
| `BiometricPrompt` class's `authenticate` method from the **AndroidX Biometric library** is used for Biometric authentication on Android devices. <br /><br />📕For details, please check [AndroidX Biometric Documentation](https://developer.android.com/jetpack/androidx/releases/biometric). |
| **Android's Native** `BiometricPrompt` API is part of the Android platform and is used for Biometric authentication on Android devices.<br /><br />📕 For details, please check [Android Developers Documentation](https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt).|
| `BiometricManager` API<br /><br /> 📕 For more details [BiometricManager Documentation](https://developer.android.com/reference/android/hardware/biometrics/BiometricManager) |
| `KeyguardManager` API <br /><br />📕 For more details [KeyguardManager Documentation](https://developer.android.com/reference/android/app/KeyguardManager) |
</div>

</TabItem>
</Tabs>

:::warning note
:::tip
The OS versions and APIs mentioned above are subject to change as per the latest OS updates and best practices recommended by Android and iOS.
:::

Expand Down
4 changes: 2 additions & 2 deletions docs/camera-image-injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import TabItem from '@theme/TabItem';
})
}}
></script>

Camera Image Injection feature allows you to test **image capturing, QR code scanning**, and **barcode scanning** functionalities in your app across **3000+ real devices** on the LambdaTest Real Device Cloud platform.

This tool is ideal for testing features such as:
Expand Down Expand Up @@ -84,7 +83,8 @@ Below given is the list of Camera APIs which are supported by LambdaTest Image I
| Supported APIs |
|----------------|
| `didFinishPickingMediaWithInfo` API of `UIImagePickerController` iOS SDK class for capturing an image. <br /><br /> 📕 For details, please check [Apple documentation](https://developer.apple.com/documentation/uikit/uiimagepickercontrollerdelegate/1619126-imagepickercontroller)|
| `AVCapturePhoto` iOS SDK class for receiving captured photos from `AVCapturePhotoOutput` API. <br /><br />📕 For details, please check [Apple Documentation](https://developer.apple.com/documentation/avfoundation/avcapturephoto). |
| `AVCapturePhoto` iOS SDK class for receiving captured photos from `AVCapturePhotoOutput` API. <br /><br />📕 For details, please check [Apple Documentation](https://developer.apple.com/documentation/avfoundation/avcapturephoto).|
| `AVMetadataMachineReadableCodeObject` is a subclass of `AVMetadataObject` iOS SDK class for scanning QR/Barcodes. <br /><br />📕 For more details, please check [AVMetadataMachineReadableCodeObject Documentation](https://developer.apple.com/documentation/avfoundation/avmetadatamachinereadablecodeobject) |
</div>

</TabItem>
Expand Down
24 changes: 2 additions & 22 deletions docs/playwright-desired-capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,5 @@ tests.
| geoLocation | AR (Argentina) | Specify country code | `const capability = { "LT:Options": {"geoLocation": "AR",}}`|
| idleTimeout | number| Specifies the timeout of the commands in seconds. <br /><br /> <b>Default value:</b> 300 <br /><br /> <b>Max value:</b> 1800<br /><br /> If a value greater than 1800 is added, idleTimeout will be set to 1800.| `const capability = { "LT:Options": {"idleTimeout": "<number>",}}`|
| lambdaMaskCommands | array | <b> `sendType` or `sendFill` </b> Masks the type method of the ElementHandle and Locator class. <br /><br /> <b>`sendPress`</b> Masks the press method of the ElementHandle and Locator class. <br /><br /> <b>`setHTTPCredentials`</b> Masks the HTTP credentials parameter in the newContext and newPage method of the browser class. <br/><br /> <b>`setStorageState`</b> Masks the storage state parameter in the newContext and newPage method of the browser class <br /><br /> <b>`setGeolocation`</b> Masks the Geolocation parameter in the newContext and newPage method of the browser class.|`const capability = { "LT:Options": {'lambdaMaskCommands': ["sendType", "sendFill", "sendPress", "setHTTPCredentials", "setStorageState", "setGeolocation"]}}` <br /><br /> |
| useSpecificBundleVersion | Boolean | If set **`true`:** LambdaTest will select the playwright server version as per the browser version you have passed in the capabilities. Check the [supported browser version list](/support/docs/playwright-test-execution-setup/#playwright-supported-browsers). <br /><br /> If the value set in the `browser version` capability is supported by multiple Playwright versions, LambdaTest checks your Playwright client version and sets the Playwright version accordingly. <br /><br /><br /> If set **`false` :** LambdaTest will run your playwright tests with the same version as setup in your local system and the browser version will also be used the compatible one as per the [supported browser version list](/support/docs/playwright-test-execution-setup/#playwright-supported-browsers) and not your defined one. | `const capabilities = { "LT:Options": {"useSpecificBundleVersion": true,}}` |


<nav aria-label="breadcrumbs">
<ul className="breadcrumbs">
<li className="breadcrumbs__item">
<a className="breadcrumbs__link" target="_self" href="https://www.lambdatest.com">
Home
</a>
</li>
<li className="breadcrumbs__item">
<a className="breadcrumbs__link" target="_self" href="https://www.lambdatest.com/support/docs/">
Support
</a>
</li>
<li className="breadcrumbs__item breadcrumbs__item--active">
<span className="breadcrumbs__link">
Capabilities for Playwright
</span>
</li>
</ul>
</nav>
| useSpecificBundleVersion | Boolean | If set **`true`:** LambdaTest will select the playwright server version as per the browser version you have passed in the capabilities. Check the [supported browser version list](/support/docs/playwright-test-execution-setup/#playwright-supported-browsers). <br /><br /> If the value set in the `browser version` capability is supported by multiple Playwright versions, LambdaTest checks your Playwright client version and sets the Playwright version accordingly. <br /><br /><br /> If set **`false` :** LambdaTest will run your playwright tests with the same version as setup in your local system and the browser version will also be used the compatible one as per the [supported browser version list](/support/docs/playwright-test-execution-setup/#playwright-supported-browsers) and not your defined one. | `const capability = { "LT:Options": {"useSpecificBundleVersion": true,}}` |
| lambdaSetBrowserPosition | | The `lambdaSetBrowserPosition` function is designed to arrange two browser windows on the screen, ensuring each occupies exactly half of the available screen space. This layout facilitates side-by-side browser comparisons or multitasking workflows. <br /> <br /> OS Supported - Windows <br /><br /> Browsers supported : Chrome, Microsoft Edge , pw-chroium, pw-webkit & pw-firefox | `const capability = {action: 'lambdaSetBrowserPosition',}` |
189 changes: 100 additions & 89 deletions docs/playwright-lighthouse library.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
id: playwright-lighthouse-library
title: How to Generate Lighthouse Reports With Playwright Lighthouse Library
hide_title: true
title: Generate Lighthouse Reports With Playwright Lighthouse Library
hide_title: false
sidebar_label: Playwright Lighthouse Library
description: Learn how to generate multiple Lighthouse reports using Playwright Lighthouse Library.
keywords:
Expand All @@ -13,6 +13,11 @@ site_name: LambdaTest
slug: playwright-lighthouse-library/
---

import CodeBlock from '@theme/CodeBlock';
import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<script type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify({
"@context": "https://schema.org",
Expand All @@ -36,112 +41,118 @@ slug: playwright-lighthouse-library/
})
}}
></script>
A Lighthouse Report is a performance, accessibility, SEO, and best practices evaluation report generated using [Google Lighthouse](https://developers.google.com/web/tools/lighthouse), an open-source, automated tool developed by Google. It is commonly used to assess and optimize the quality of web pages.

LambdaTest lets you perform Playwright automation while allowing you to generate Lighthouse reports with Playwright Lighthouse Library in a single test.

# Generating Lighthouse Reports With Playwright Lighthouse Library
---
> Lighthouse Report is supported on **Chrome**, **MicrosoftEdge** and **Chromium** browsers.

LambdaTest lets you perform Playwright automation while allowing you to generate Lighthouse reports with Playwright Lighthouse Library in a single test.
:::tip Sample repository
The code sample for generating the Lighthouse Performance Metrics in the Playwright test can be found on **LambdaTest's GitHub Repository**. You can either download or clone the repository to quickly run your tests. <a href="https://github.com/LambdaTest/playwright-sample/blob/main/playwright-lighthouse-report.js" className="github__anchor"><img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub</a>
:::

## Prerequisites
---
- Ensure that you have the Playwright Lighthouse Library installed in your web project.
```bash
npm install playwright-lighthouse
```

- Export the *LIGHTHOUSE_LAMBDATEST* environment variable to your project environment.
```bash
export LIGHTHOUSE_LAMBDATEST='true'
```

## Write your Test Script
:::info
Generating lighthouse report within the test might increase the test duration. It is advisable to generate the lighthouse reports only in the required tests.
:::

You can easily add the Lighthouse Performance Metrics of the website you want to test by using the `lighthouseReport` action via the test. Following is the code snippet for generating Lighthouse report from the Playwright if you are using JavaScript:
```js title="playwright-lighthouse-report.js"
await page.evaluate(_ => {}, `lambdatest_action: ${JSON.stringify({
action: 'lighthouseReport',
arguments: { url: 'https://www.example.com' }
})}`)
```

You can generate Lighthouse reports on LambdaTest platform while executing Playwright tests with the following steps.
### For Authenticated Pages
> This feature is only supported on **Windows** and **macOS** platforms.

1. Ensure that you have the Playwright Lighthouse Library installed in your web project.
The feature allows you to generate Lighthouse reports for authenticated web pages using Playwright. This is particularly useful for testing performance, accessibility, SEO, and other quality metrics for pages that require authentication. By leveraging authentication tokens, you can analyze restricted pages in your Playwright tests on both **Windows** and **macOS** environments.

```bash
npm install playwright-lighthouse
<Tabs className="docs__val">
<TabItem value="win" label="Windows" default>

```javascript
await page.evaluate(() => {}, `lambdatest_action: ${JSON.stringify({
action: 'lighthouseReport',
arguments: { url: 'https://www.example.com',
args: `--extra-headers
${JSON.stringify({ authtoken: "YOUR_AUTH_TOKEN" })}`
} })}` );
```
</TabItem>

2. Export the *LIGHTHOUSE_LAMBDATEST* environment variable to your project environment.
<TabItem value="mac" label="macOS" default>

```bash
export LIGHTHOUSE_LAMBDATEST='true'
```javascript
await page.evaluate(() => {}, `lambdatest_action: ${JSON.stringify({
action: 'lighthouseReport',
arguments: { url: 'https://www.example.com',
args: '--extra-headers
"{\\"authtoken\\": \\"YOUR_AUTH_TOKEN\\"}"'
} })}`);
```
</TabItem>
</Tabs>

## Run the Test
---
### Sample Test Script

This following script performs web automation testing using the Playwright and Lighthouse libraries on the LambdaTest platform. The script navigates to the DuckDuckGo search engine and searches for the term "Playwright". After that, the script runs a Lighthouse audit on the specified URL (https://duckduckgo.com) with defined performance thresholds and report formats.

This following script performs web automation testing using the Playwright and Lighthouse libraries on the LambdaTest platform.The script navigates to the DuckDuckGo search engine and searches for the term "Playwright". After that, the script runs a Lighthouse audit on the specified URL (https://duckduckgo.com) with defined performance thresholds and report formats.

```js
import { chromium } from "playwright";
import { playAudit } from "playwright-lighthouse";

(async () => {
let browser, page;
try {
const capabilities = {
browserName: "Chrome", // Browsers allowed: `Chrome`, `MicrosoftEdge` and `pw-chromium`
browserVersion: "latest",
"LT:Options": {
platform: "Windows 11",
build: "Web Performance testing",
name: "Lighthouse test",
user: process.env.LT_USERNAME,
accessKey: process.env.LT_ACCESS_KEY,
network: true,
video: true,
console: true,
},
};

browser = await chromium.connect({
wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
});

page = await browser.newPage();

await page.goto("https://duckduckgo.com");
let element = await page.locator('[name="q"]');
await element.click();
await element.type("Playwright");
await element.press("Enter");

try {
await playAudit({
url: "https://duckduckgo.com",
page: page,
thresholds: {
performance: 50,
accessibility: 50,
"best-practices": 50,
seo: 50,
pwa: 10,
},
reports: {
formats: {
json: true,
html: true,
csv: true,
},
},
});

await page.evaluate((_) => {},
`lambdatest_action: ${JSON.stringify({ action: "setTestStatus", arguments: { status: "passed", remark: "Web performance metrics are are above the thresholds." } })}`);
} catch (e) {
await page.evaluate((_) => {},
`lambdatest_action: ${JSON.stringify({ action: "setTestStatus", arguments: { status: "failed", remark: e.stack } })}`);
console.error(e);
}
} catch (e) {
await page.evaluate((_) => {},
`lambdatest_action: ${JSON.stringify({ action: "setTestStatus", arguments: { status: "failed", remark: e.stack } })}`);
} finally {
await page.close();
await browser.close();
}
})();
```javascript reference title="playwright-lighthouse-report.js"
https://github.com/LambdaTest/playwright-sample/blob/main/playwright-lighthouse-report.js
```

## View Your Test Results
---
## Trigger your Test on LambdaTest
### Set up your authentication

Make sure you have your LambdaTest credentials with you to run test automation scripts on LambdaTest. To obtain your access credentials, [purchase a plan](https://billing.lambdatest.com/billing/plans) or access the [Automation Dashboard](https://appautomation.lambdatest.com/). Then, set LambdaTest `Username` and `Access Key` in environment variables with following commands.

<Tabs className="docs__val">

<TabItem value="bash" label="Linux / MacOS" default>
<div className="lambdatest__codeblock">
<CodeBlock className="language-bash">
{`export LT_USERNAME=${ YOUR_LAMBDATEST_USERNAME()}
export LT_ACCESS_KEY=${ YOUR_LAMBDATEST_ACCESS_KEY()}`}
</CodeBlock>
</div>

</TabItem>

<TabItem value="powershell" label="Windows" default>

<div className="lambdatest__codeblock">
<CodeBlock className="language-powershell">
{`set LT_USERNAME=${ YOUR_LAMBDATEST_USERNAME()}
set LT_ACCESS_KEY=${ YOUR_LAMBDATEST_ACCESS_KEY()}`}
</CodeBlock>
</div>

</TabItem>
</Tabs>

### Run your test
Pass the below command in the terminal to run the test:
```bash
node RELATIVE_PATH_OF_YOUR_TEST_FILE
```

### View Your Test Results
To view your test runs that uses Playwright Lighthouse Library, go to the LambdaTest [Web Automation Dashboard](https://automation.lambdatest.com/).

<img loading="lazy" src={require('../assets/images/uploads/playwright_lighthouse_lib.png').default} alt="Image" width="1347" height="565" className="doc_img"/>
<img loading="lazy" src={require('../assets/images/playwright-testing/lighthouse-report.png').default} alt="Image" className="doc_img"/>



Expand Down
Loading
Loading