id | title | hide_title | sidebar_label | description | keywords | url | site_name | slug | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
playwright-real-device-on-hyperexecute |
Run playwright automation tests on HyperExecute using Real Devices |
true |
Real Device |
Learn how to run playwright automation tests using Real Devices on HyperExecute |
|
LambdaTest |
playwright-real-device-on-hyperexecute/ |
import CodeBlock from '@theme/CodeBlock'; import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys";
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify({ "@context": "https://schema.org", "@type": "BreadcrumbList", "itemListElement": [{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https://www.lambdatest.com" },{ "@type": "ListItem", "position": 2, "name": "Support", "item": "https://www.lambdatest.com/support/docs/" },{ "@type": "ListItem", "position": 3, "name": "How to run playwright real deices automation tests on HyperExecute", "item": "https://www.lambdatest.com/support/docs/playwright-real-device-on-hyperexecute/" }] }) }} ></script>This guide details how to execute your Playwright Real Device tests on HyperExecute:
To run the Tests on HyperExecute from your Local System, you are required:
- Your LambdaTest Username and Access key
- HyperExecute YAML file which contains all the necessary instructions.
- HyperExecute CLI in order to initiate a test execution Job .
- Setup the Environmental Variable
You can use your own project to configure and test it. For demo purposes, we are using the sample repository.
:::tip Sample repo
Download or Clone the code sample for the Playwright Real Device from the LambdaTest GitHub repository to run the tests on the HyperExecute.
:::
Configure the desired capabilities based on your test requirements. For example:
const capabilities = {
'browserName': 'Chrome', #Browsers allowed: `Chrome`, `MicrosoftEdge`, `pw-chromium`, `pw-firefox` and `pw-webkit`
'browserVersion': 'latest',
'LT:Options': {
'platform': 'android',
'build': 'Playwright HyperExecute Build',
'name': 'Playwright HyperExecute Test',
'user': '<your_lambdatest_user_name>',
'accessKey': '<your_lambdatest_access_key>',
# 'network': true,
'video': true,
'console': true
}
}
You can also use dev and beta browser versions. To generate capabilities for your test requirements, you can use our inbuilt 🔗 Capabilities Generator Tool.
- You will have to update the CDP (Chrome DevTools Protocol) URL which is a protocol used for communication between the browser and the developer tools.
const browser = await chromium.connect({
wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
})
After cloning / downloading the sample repo, you need to setup the CLI and the environment variables.
The CLI is used for triggering the tests on HyperExecute. It is recommend to download the CLI binary on the host system and keep it in the root directory of the suite to perform the tests on HyperExecute.
You can download the CLI for your desired platform from the below mentioned links:
Now, you need to export your environment variables LT_USERNAME and LT_ACCESS_KEY that are available in the LambdaTest Profile page.
Run the below mentioned commands in your terminal to setup the CLI and the environment variables.
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Configure your YAML file as per your use cases using key value pairs.
In this sample YAML file, we have mentioned:
- version of the YAML file
- runson flag to specify the operating system
- Mode of execution is Autosplit. You can also opt for Matrix or Hybrid mode.
- Pre and Post commands
- and other necessary YAML Parameters
---
version: "0.2"
runson: android
autosplit: true
concurrency: 1
retryOnFailure: true
maxRetries: 2
cacheKey: '{{ checksum "package-lock.json" }}'
cacheDirectories:
- node_modules
env:
INFRA_TIMEOUT: 2000
runtime:
language: node
version: "18"
pre:
- npm install
- npx playwright install
testDiscovery:
command: cat pw_androidtests.txt
mode: static
type: raw
testRunnerCommand: npm run test-android --verbose
# highlight-start
framework:
name: appium
args:
playwrightRD : true
region: eu
# highlight-end
jobLabel: ['Playwright', 'Real-Device', 'HyperExecute']
:::info To Run test on Mobile Containers in a Particular Region
dynamicAllocation: true
framework:
name: appium
args:
playwrightRD : true
region: ap # supported regions -> ap, eu, us
reservation: false
- If
reservation : false
, it means that it will allocate the device from any region. If you want to allocate the device of any specific region, keep thereservation : true
.
:::
NOTE : In case of MacOS, if you get a permission denied warning while executing CLI, simply run
chmod u+x ./hyperexecute
to allow permission. In case you get a security popup, allow it from your System Preferences → Security & Privacy → General tab.
Run the below command in your terminal at the root folder of the project:
./hyperexecute --config RELATIVE_PATH_OF_YOUR_YAML_FILE
OR use this command if you have not exported your username and access key in the step 2.
<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/playwright/real-device/1.png').default} alt="JUnit HyperExecute Terminal Logs" width="1920" height="868" className="doc_img"/>
<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/playwright/real-device/2.png').default} alt="JUnit HyperExecute Terminal Logs" width="1920" height="868" className="doc_img"/>
Visit the HyperExecute Dashboard and check your Job status.
<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/playwright/real-device/3.png').default} alt="automation-dashboard" width="1920" height="868" className="doc_img"/>
HyperExecute also facilitates the provision to download the Artifacts and Reports on your local machine. Click on the corresponding button to download your generated artifacts and reports.
<img loading="lazy" src={require('../assets/images/hyperexecute/frameworks/playwright/real-device/4.png').default} alt="automation-dashboard" width="1920" height="868" className="doc_img"/>