File tree Expand file tree Collapse file tree 6 files changed +138
-0
lines changed Expand file tree Collapse file tree 6 files changed +138
-0
lines changed File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ const { chromium } = require ( "playwright" ) ;
2
+ const { expect } = require ( "@playwright/test" ) ;
3
+ const smartuiSnapshot = require ( "@lambdatest/playwright-driver" ) ;
4
+
5
+
6
+ // username: Username can be found at automation dashboard
7
+ const USERNAME = process . env . LT_USERNAME || "<USERNAME>" ;
8
+
9
+ // AccessKey: AccessKey can be generated from automation dashboard or profile section
10
+ const KEY = process . env . LT_ACCESS_KEY || "<ACCESS_KEY>" ;
11
+ ( async ( ) => {
12
+ const capabilities = {
13
+ browserName : "Chrome" ,
14
+ browserVersion : "latest" ,
15
+ "LT:Options" : {
16
+ platform : "Windows 10" ,
17
+ build : "Playwright SmartUI Build" ,
18
+ name : "Playwright SmartUI Test" ,
19
+ user : USERNAME ,
20
+ accessKey : KEY ,
21
+ network : true ,
22
+ video : true ,
23
+ console : true ,
24
+ } ,
25
+ } ;
26
+
27
+ const githubURL = process . env . GITHUB_URL ;
28
+ if ( githubURL ) {
29
+ capabilities [ "LT:Options" ] [ "github" ] = {
30
+ url : githubURL ,
31
+ } ;
32
+ }
33
+
34
+ const browser = await chromium . connect ( {
35
+ wsEndpoint : `wss://cdp.lambdatest.com/playwright?capabilities=${ encodeURIComponent (
36
+ JSON . stringify ( capabilities )
37
+ ) } `,
38
+ } ) ;
39
+
40
+ const page = await browser . newPage ( ) ;
41
+
42
+ await page . goto ( "https://ipinfo.io/" ) ;
43
+ options = {
44
+ ignoreDOM : {
45
+ xpath : [ '//*[@id="__next"]/div/div/main/section[4]' ] ,
46
+ }
47
+ }
48
+ // Add the following command in order to take screenshot in SmartUI
49
+ await smartuiSnapshot . smartuiSnapshot ( page , "Ignore-ticker" , options ) ;
50
+ await browser . close ( ) ;
51
+ } ) ( ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " lambdatest-playwright-sample" ,
3
+ "scripts" : {
4
+ "test" : " node playwright-single.js" ,
5
+ "test-smartui" : " node playwright-smartui.js"
6
+ },
7
+ "engines" : {
8
+ "node" : " >=12.7.0"
9
+ },
10
+ "devDependencies" : {
11
+ "@playwright/test" : " ^1.35.0" ,
12
+ "playwright" : " ^1.35.0" ,
13
+ "@cucumber/cucumber" : " ^7.3.2" ,
14
+ "chai" : " ^4.3.7"
15
+ },
16
+ "dependencies" : {
17
+ "@lambdatest/playwright-driver" : " ^1.0.3" ,
18
+ "@lambdatest/smartui-cli" : " ^2.0.6"
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ const { chromium } = require ( "playwright" ) ;
2
+ const { expect } = require ( "@playwright/test" ) ;
3
+ const smartuiSnapshot = require ( "@lambdatest/playwright-driver" ) ;
4
+
5
+
6
+ // username: Username can be found at automation dashboard
7
+ const USERNAME = process . env . LT_USERNAME || "<USERNAME>" ;
8
+
9
+ // AccessKey: AccessKey can be generated from automation dashboard or profile section
10
+ const KEY = process . env . LT_ACCESS_KEY || "<ACCESS_KEY>" ;
11
+ ( async ( ) => {
12
+ const capabilities = {
13
+ browserName : "Chrome" ,
14
+ browserVersion : "latest" ,
15
+ "LT:Options" : {
16
+ platform : "Windows 10" ,
17
+ build : "Playwright SmartUI Build" ,
18
+ name : "Playwright SmartUI Test" ,
19
+ user : USERNAME ,
20
+ accessKey : KEY ,
21
+ network : true ,
22
+ video : true ,
23
+ console : true ,
24
+ } ,
25
+ } ;
26
+
27
+ const githubURL = process . env . GITHUB_URL ;
28
+ if ( githubURL ) {
29
+ capabilities [ "LT:Options" ] [ "github" ] = {
30
+ url : githubURL ,
31
+ } ;
32
+ }
33
+
34
+ const browser = await chromium . connect ( {
35
+ wsEndpoint : `wss://cdp.lambdatest.com/playwright?capabilities=${ encodeURIComponent (
36
+ JSON . stringify ( capabilities )
37
+ ) } `,
38
+ } ) ;
39
+
40
+ const page = await browser . newPage ( ) ;
41
+
42
+ await page . goto ( "https://www.lambdatest.com" ) ;
43
+
44
+ // Add the following command in order to take screenshot in SmartUI
45
+ await smartuiSnapshot . smartuiSnapshot ( page , "LT-Home" ) ;
46
+ await browser . close ( ) ;
47
+ } ) ( ) ;
Original file line number Diff line number Diff line change
1
+ const { chromium } = require ( "playwright" ) ;
2
+ const smartuiSnapshot = require ( "@lambdatest/playwright-driver" ) ;
3
+
4
+ ( async ( ) => {
5
+ // Launch a local browser instance
6
+ const browser = await chromium . launch ( {
7
+ headless : false , // Set to false to see the browser UI
8
+ } ) ;
9
+
10
+ const page = await browser . newPage ( ) ;
11
+
12
+ // Navigate to the desired URL
13
+ await page . goto ( "https://www.lambdatest.com" ) ;
14
+
15
+ // Use smartuiSnapshot to take a visual snapshot locally
16
+ await smartuiSnapshot . smartuiSnapshot ( page , "LT-Home" ) ;
17
+
18
+ // Close the browser
19
+ await browser . close ( ) ;
20
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments