|
| 1 | +--- |
| 2 | +id: playwright-webview-test |
| 3 | +title: Playwright Webdview Testing |
| 4 | +hide_title: false |
| 5 | +sidebar_label: Webview Testing |
| 6 | +description: Learn how to perform webview testing on android using playwright framework on lambdatest platform with 3000+ browsers cross platform. |
| 7 | +keywords: |
| 8 | + - playwright testing |
| 9 | + - playwright mobile testing |
| 10 | + - playwright testing tool |
| 11 | + - playwright testing on lambdatest |
| 12 | + - playwright testing lambdatest |
| 13 | + - playwright android |
| 14 | +url: https://www.lambdatest.com/support/docs/playwright-webview-test/ |
| 15 | +site_name: LambdaTest |
| 16 | +slug: playwright-webview-test/ |
| 17 | +--- |
| 18 | + |
| 19 | +import Tabs from '@theme/Tabs'; |
| 20 | +import TabItem from '@theme/TabItem'; |
| 21 | +import CodeBlock from '@theme/CodeBlock'; |
| 22 | +import {YOUR_LAMBDATEST_USERNAME, YOUR_LAMBDATEST_ACCESS_KEY} from "@site/src/component/keys"; |
| 23 | + |
| 24 | +<script type="application/ld+json" |
| 25 | + dangerouslySetInnerHTML={{ __html: JSON.stringify({ |
| 26 | + "@context": "https://schema.org", |
| 27 | + "@type": "BreadcrumbList", |
| 28 | + "itemListElement": [{ |
| 29 | + "@type": "ListItem", |
| 30 | + "position": 1, |
| 31 | + "name": "LambdaTest", |
| 32 | + "item": "https://www.lambdatest.com" |
| 33 | + },{ |
| 34 | + "@type": "ListItem", |
| 35 | + "position": 2, |
| 36 | + "name": "Support", |
| 37 | + "item": "https://www.lambdatest.com/support/docs/" |
| 38 | + },{ |
| 39 | + "@type": "ListItem", |
| 40 | + "position": 3, |
| 41 | + "name": "Playwright Android Webview Testing", |
| 42 | + "item": "https://www.lambdatest.com/support/docs/playwright-webview-test/" |
| 43 | + }] |
| 44 | + }) |
| 45 | + }} |
| 46 | +></script> |
| 47 | +WebView testing is an essential process for ensuring the functionality and reliability of applications that rely on embedded web browsers. This guide provides detailed steps to perform WebView testing using Playwright. It is designed for developers, QA engineers, and anyone involved in software quality assurance. |
| 48 | + |
| 49 | +## Steps to perform Webview testing |
| 50 | + |
| 51 | +### Step 1: Setup your test suite |
| 52 | + |
| 53 | +You can use your own project to configure and test it. For demo purposes, we are using the sample repository. |
| 54 | + |
| 55 | +:::tip sample repo |
| 56 | +Download or Clone the code sample from the LambdaTest GitHub repository to run your tests. |
| 57 | + |
| 58 | +<a href="https://github.com/LambdaTest/playwright-sample/blob/main/playwrightwebview.js" className="github__anchor"><img loading="lazy" src={require('../assets/images/icons/github.png').default} alt="Image" className="doc_img"/> View on GitHub</a> |
| 59 | +::: |
| 60 | + |
| 61 | +- If you are using your own project, configure the `browserWSEndpoint` (browser end point URL) in your test script to run the test on LambdaTest |
| 62 | + |
| 63 | +```javascript |
| 64 | +wsEndpoint: `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}` |
| 65 | +``` |
| 66 | + |
| 67 | +- Here is the sample test script for your reference: |
| 68 | + |
| 69 | +```javascript reference title="playwrightwebview.js" |
| 70 | +https://github.com/LambdaTest/playwright-sample/blob/main/playwrightwebview.js |
| 71 | +``` |
| 72 | + |
| 73 | +### Step 2: Update the dependencies |
| 74 | +Before proceeding forward, run the below command to update the outdated dependencies |
| 75 | + |
| 76 | +```bash |
| 77 | +npm install |
| 78 | +``` |
| 79 | + |
| 80 | +### Step 3: Update your test Capabilities |
| 81 | +Include the following field in the capabilities object to enable WebView testing: |
| 82 | + |
| 83 | +```javascript title="playwrightwebview.js" |
| 84 | +const capabilities = { |
| 85 | + "LT:Options": { |
| 86 | + "platformName": "android", |
| 87 | + "isRealMobile": true, //if true, test will run on real devices |
| 88 | + // highlight-next-line |
| 89 | + "isPwMobileWebviewTest": true, //mandatory capability to enable WebView testing |
| 90 | + }, |
| 91 | +``` |
| 92 | +
|
| 93 | +:::tip |
| 94 | +Use our [Capability Generator](https://www.lambdatest.com/capabilities-generator/) to select from a wide range of options for customizing your tests. |
| 95 | +::: |
| 96 | +
|
| 97 | +### Step 4: Setup your LambdaTest credentials |
| 98 | +
|
| 99 | +In your terminal (as per your respective Operating System), run these command to setup your LambdaTest credentials. |
| 100 | +> You can see your credentials below if you have logged into our platform. |
| 101 | +
|
| 102 | +<Tabs className="docs__val"> |
| 103 | +
|
| 104 | +<TabItem value="bash" label="Linux / MacOS" default> |
| 105 | +
|
| 106 | + <div className="lambdatest__codeblock"> |
| 107 | + <CodeBlock className="language-bash"> |
| 108 | + {`export LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}" |
| 109 | +export LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`} |
| 110 | + </CodeBlock> |
| 111 | +</div> |
| 112 | +
|
| 113 | +</TabItem> |
| 114 | +
|
| 115 | +<TabItem value="powershell" label="Windows" default> |
| 116 | +
|
| 117 | + <div className="lambdatest__codeblock"> |
| 118 | + <CodeBlock className="language-powershell"> |
| 119 | + {`set LT_USERNAME="${ YOUR_LAMBDATEST_USERNAME()}" |
| 120 | +set LT_ACCESS_KEY="${ YOUR_LAMBDATEST_ACCESS_KEY()}"`} |
| 121 | + </CodeBlock> |
| 122 | +</div> |
| 123 | +
|
| 124 | +</TabItem> |
| 125 | +</Tabs> |
| 126 | +
|
| 127 | +### Step 5: Execute your test |
| 128 | +Replace the `TEST_FILE_NAME` in the below command with your desired test file to execute that particular test on LambdaTest: |
| 129 | +
|
| 130 | +```bash |
| 131 | +node playwrightwebview.js |
| 132 | +``` |
| 133 | +
|
| 134 | +Visit the [LambdaTest Web Automation](https://automation.lambdatest.com/build) page to check the status of your test execution. |
| 135 | +<img loading="lazy" src={require('../assets/images/playwright-testing/webview-test.png').default} alt="Image" className="doc_img"/> |
| 136 | +
|
0 commit comments