1+ import { test } from '@playwright/test' ;
2+ import { BatchInfo , Configuration , EyesRunner , VisualGridRunner , BrowserType , DeviceName , ScreenOrientation , Eyes , Target } from '@applitools/eyes-playwright' ;
3+
4+ export let Batch : BatchInfo ;
5+ export let Config : Configuration ;
6+ export let Runner : EyesRunner ;
7+
8+ test . beforeAll ( async ( ) => {
9+
10+ // Configure Applitools SDK to run on the Ultrafast Grid
11+ Runner = new VisualGridRunner ( { testConcurrency : 5 } ) ;
12+ Batch = new BatchInfo ( { name : `Applitools Quickstart` } ) ;
13+
14+ Config = new Configuration ( ) ;
15+ Config . setBatch ( Batch ) ;
16+ Config . addBrowsers (
17+ { name : BrowserType . CHROME , width : 800 , height : 600 } ,
18+ { name : BrowserType . FIREFOX , width : 1600 , height : 1200 } ,
19+ { name : BrowserType . SAFARI , width : 1024 , height : 768 } ,
20+ { chromeEmulationInfo : { deviceName : DeviceName . iPhone_11 , screenOrientation : ScreenOrientation . PORTRAIT } } ,
21+ { chromeEmulationInfo : { deviceName : DeviceName . Nexus_10 , screenOrientation : ScreenOrientation . LANDSCAPE } }
22+ )
23+ } ) ;
24+
25+ test . describe ( 'ACME Bank' , ( ) => {
26+ let eyes : Eyes ;
27+ test . beforeEach ( async ( { page } ) => {
28+ eyes = new Eyes ( Runner , Config ) ;
29+
30+ // Start Applitools Visual AI Test
31+ // Args: Playwright Page, App Name, Test Name, Viewport Size for local driver
32+ await eyes . open ( page , 'ACME Bank' , test . info ( ) . title , { width : 1200 , height : 600 } )
33+ } ) ;
34+
35+ test ( 'log into a bank account' , async ( { page } ) => {
36+ await page . goto ( 'https://sandbox.applitools.com/bank?layoutAlgo=true' ) ;
37+
38+ // Full Page - Visual AI Assertion
39+ await eyes . check ( 'Login page' , Target . window ( ) . fully ( ) ) ;
40+
41+ await page . locator ( 'id=username' ) . fill ( 'user' ) ;
42+ await page . locator ( 'id=password' ) . fill ( 'password' ) ;
43+ await page . locator ( 'id=log-in' ) . click ( ) ;
44+ await page . locator ( 'css=.dashboardNav_navContainer__kA4wD' ) . waitFor ( { state : 'attached' } ) ;
45+
46+ // Full Page - Visual AI Assertion
47+ await eyes . check ( 'Main page' , Target . window ( ) . fully ( )
48+ . layoutRegions (
49+ '.dashboardOverview_accountBalances__3TUPB' ,
50+ '.dashboardTable_dbTable___R5Du'
51+ )
52+ ) ;
53+ } ) ;
54+
55+ test . afterEach ( async ( ) => {
56+ // End Applitools Visual AI Test
57+ await eyes . close ( ) ;
58+ } ) ;
59+ } ) ;
60+
61+ test . afterAll ( async ( ) => {
62+ // Wait for Ultrast Grid Renders to finish and gather results
63+ const results = await Runner . getAllTestResults ( ) ;
64+ console . log ( 'Visual test results' , results ) ;
65+ } ) ;
0 commit comments