diff --git a/.gitignore b/.gitignore index 6523b69..4fafcf8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ local.log local.log package-lock.json local.log +.obs_test_details-* +/log +/test-results diff --git a/fixture.js b/fixture.js index f9ef1b2..44e68d9 100644 --- a/fixture.js +++ b/fixture.js @@ -32,7 +32,7 @@ exports.BS_LOCAL_ARGS = { }; // Patching the capabilities dynamically according to the project name. -const patchMobileCaps = (name, title) => { +const patchAndroidCaps = (name, title) => { let combination = name.split(/@browserstack/)[0]; let [browerCaps, osCaps] = combination.split(/:/); let [browser, deviceName] = browerCaps.split(/@/); @@ -60,6 +60,20 @@ const patchCaps = (name, title) => { caps.name = title; }; +const patchIosCaps = (name, title) => { + let combination = name.split(/@browserstack/)[0]; + let [browerCaps, osCaps] = combination.split(/:/); + let [browser, deviceName] = browerCaps.split(/@/); + let osCapsSplit = osCaps.split(/ /); + let os = osCapsSplit.shift(); + let osVersion = osCapsSplit.join(" "); + caps.browser = browser ? browser : "safari"; + caps.deviceName = deviceName ? deviceName : "Iphone 16"; + caps.osVersion = osVersion ? osVersion : "18"; + caps.name = title; + caps.realMobile = "true"; +}; + const isHash = (entity) => Boolean(entity && typeof entity === "object" && !Array.isArray(entity)); const nestedKeyValue = (hash, keys) => @@ -82,9 +96,10 @@ exports.test = base.test.extend({ page: async ({ page, playwright }, use, testInfo) => { if (testInfo.project.name.match(/browserstack/)) { let vBrowser, vContext, vDevice; - const isMobile = testInfo.project.name.match(/browserstack-mobile/); - if (isMobile) { - patchMobileCaps( + const isAndroid = testInfo.project.name.match(/browserstack-android/); + const isIOS = testInfo.project.name.match(/browserstack-ios/); + if (isAndroid) { + patchAndroidCaps( testInfo.project.name, `${testInfo.file} - ${testInfo.title}` ); @@ -95,6 +110,18 @@ exports.test = base.test.extend({ ); await vDevice.shell("am force-stop com.android.chrome"); vContext = await vDevice.launchBrowser(); + } else if(isIOS) { + patchIosCaps( + testInfo.project.name, + `${testInfo.file} - ${testInfo.title}` + ); + + vBrowser = await playwright.webkit.connect({ + wsEndpoint: + `wss://cdp.browserstack.com/playwright?caps=` + + `${encodeURIComponent(JSON.stringify(caps))}`, + }); + vContext = await vBrowser.newContext(testInfo.project.use); } else { patchCaps(testInfo.project.name, `${testInfo.title}`); delete caps.osVersion; @@ -112,7 +139,7 @@ exports.test = base.test.extend({ await vPage.close(); - if (isMobile) { + if (isAndroid) { await vDevice.close(); } else { await vBrowser.close(); @@ -123,31 +150,50 @@ exports.test = base.test.extend({ }, beforeEach: [ - async ({ page }, use) => { - await page - .context() - .tracing.start({ screenshots: true, snapshots: true, sources: true }); - await use(); + async ({ page }, use, testInfo) => { + const isIOS = testInfo.project.name.match(/browserstack-ios/); + if(isIOS) { + await page.context(); + await use(); + } else { + await page + .context() + .tracing.start({ screenshots: true, snapshots: true, sources: true }); + await use(); + } }, { auto: true }, ], afterEach: [ async ({ page }, use, testInfo) => { + const isIOS = testInfo.project.name.match(/browserstack-ios/); await use(); - if (testInfo.status == "failed") { - await page - .context() - .tracing.stop({ path: `${testInfo.outputDir}/trace.zip` }); - await page.screenshot({ path: `${testInfo.outputDir}/screenshot.png` }); - await testInfo.attach("screenshot", { - path: `${testInfo.outputDir}/screenshot.png`, - contentType: "image/png", - }); - await testInfo.attach("trace", { - path: `${testInfo.outputDir}/trace.zip`, - contentType: "application/zip", - }); + + if(isIOS) { + if (testInfo.status == "failed") { + await page.context(); + await page.screenshot({ path: `${testInfo.outputDir}/screenshot.png` }); + await testInfo.attach("screenshot", { + path: `${testInfo.outputDir}/screenshot.png`, + contentType: "image/png", + }); + } + } else { + if (testInfo.status == "failed") { + await page + .context() + .tracing.stop({ path: `${testInfo.outputDir}/trace.zip` }); + await page.screenshot({ path: `${testInfo.outputDir}/screenshot.png` }); + await testInfo.attach("screenshot", { + path: `${testInfo.outputDir}/screenshot.png`, + contentType: "image/png", + }); + await testInfo.attach("trace", { + path: `${testInfo.outputDir}/trace.zip`, + contentType: "application/zip", + }); + } } }, { auto: true }, diff --git a/package-lock.json b/package-lock.json index 3e1d9ad..9abbac5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,49 +1,69 @@ { "name": "v1.28_playwright_test", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 3, "requires": true, - "dependencies": { - "@playwright/test": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.39.0.tgz", - "integrity": "sha512-3u1iFqgzl7zr004bGPYiN/5EZpRUSFddQBra8Rqll5N0/vfpqlP9I9EXqAoGacuAbX6c9Ulg/Cjqglp5VkK6UQ==", + "packages": { + "": { + "name": "v1.28_playwright_test", + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "@playwright/test": "latest", + "browserstack-local": "^1.5.1", + "playwright": "latest", + "prettier": "2.8.8" + } + }, + "node_modules/@playwright/test": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.52.0.tgz", + "integrity": "sha512-uh6W7sb55hl7D6vsAeA+V2p5JnlAqzhqFyF0VcJkKZXkgnFcVG9PziERRHQfPLfNGx1C292a4JqbWzhR8L4R1g==", "dev": true, - "requires": { - "playwright": "1.39.0" + "dependencies": { + "playwright": "1.52.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" } }, - "agent-base": { + "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", "dev": true, - "requires": { + "dependencies": { "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" } }, - "balanced-match": { + "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, - "brace-expansion": { + "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, - "requires": { + "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, - "browserstack-local": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/browserstack-local/-/browserstack-local-1.5.1.tgz", - "integrity": "sha512-T/wxyWDzvBHbDvl7fZKpFU7mYze6nrUkBhNy+d+8bXBqgQX10HTYvajIGO0wb49oGSLCPM0CMZTV/s7e6LF0sA==", + "node_modules/browserstack-local": { + "version": "1.5.6", + "resolved": "https://registry.npmjs.org/browserstack-local/-/browserstack-local-1.5.6.tgz", + "integrity": "sha512-s0GadAkyE1XHxnmymb9atogTZbA654bcFpqGkcYEtYPaPvuvVfSXR0gw8ojn0I0Td2HEMJcGtdrkBjb1Fi/HmQ==", "dev": true, - "requires": { + "dependencies": { "agent-base": "^6.0.2", "https-proxy-agent": "^5.0.1", "is-running": "^2.1.0", @@ -51,33 +71,41 @@ "temp-fs": "^0.9.9" } }, - "concat-map": { + "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, - "debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "dev": true, - "requires": { - "ms": "2.1.2" + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, - "duplexer": { + "node_modules/duplexer": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==", "dev": true }, - "event-stream": { + "node_modules/event-stream": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", "integrity": "sha512-QHpkERcGsR0T7Qm3HNJSyXKEEj8AHNxkY3PK8TS2KJvQ7NiSHe3DDpwVKKtoYprL/AreyzFBeIkBIWChAqn60g==", "dev": true, - "requires": { + "dependencies": { "duplexer": "~0.1.1", "from": "~0", "map-stream": "~0.1.0", @@ -87,190 +115,253 @@ "through": "~2.3.1" } }, - "from": { + "node_modules/from": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", "integrity": "sha512-twe20eF1OxVxp/ML/kq2p1uc6KvFK/+vs8WjEbeKmV2He22MKm7YF2ANIt+EOqhJ5L3K/SuuPhk0hWQDjOM23g==", "dev": true }, - "fs.realpath": { + "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, - "fsevents": { + "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "dev": true, - "optional": true + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } }, - "glob": { + "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", "dev": true, - "requires": { + "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "https-proxy-agent": { + "node_modules/https-proxy-agent": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", "dev": true, - "requires": { + "dependencies": { "agent-base": "6", "debug": "4" + }, + "engines": { + "node": ">= 6" } }, - "inflight": { + "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", "dev": true, - "requires": { + "dependencies": { "once": "^1.3.0", "wrappy": "1" } }, - "inherits": { + "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, - "is-running": { + "node_modules/is-running": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-running/-/is-running-2.1.0.tgz", "integrity": "sha512-mjJd3PujZMl7j+D395WTIO5tU5RIDBfVSRtRR4VOJou3H66E38UjbjvDGh3slJzPuolsb+yQFqwHNNdyp5jg3w==", "dev": true }, - "map-stream": { + "node_modules/map-stream": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", "integrity": "sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==", "dev": true }, - "minimatch": { + "node_modules/minimatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, - "requires": { + "dependencies": { "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" } }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "once": { + "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, - "requires": { + "dependencies": { "wrappy": "1" } }, - "path-is-absolute": { + "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "dev": true + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "pause-stream": { + "node_modules/pause-stream": { "version": "0.0.11", "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", "integrity": "sha512-e3FBlXLmN/D1S+zHzanP4E/4Z60oFAa3O051qt1pxa7DEJWKAyil6upYVXCWadEnuoqa4Pkc9oUx9zsxYeRv8A==", "dev": true, - "requires": { + "dependencies": { "through": "~2.3" } }, - "playwright": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.39.0.tgz", - "integrity": "sha512-naE5QT11uC/Oiq0BwZ50gDmy8c8WLPRTEWuSSFVG2egBka/1qMoSqYQcROMT9zLwJ86oPofcTH2jBY/5wWOgIw==", + "node_modules/playwright": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.52.0.tgz", + "integrity": "sha512-JAwMNMBlxJ2oD1kce4KPtMkDeKGHQstdpFPcPH3maElAXon/QZeTvtsfXmTMRyO9TslfoYOXkSsvao2nE1ilTw==", "dev": true, - "requires": { - "fsevents": "2.3.2", - "playwright-core": "1.39.0" + "dependencies": { + "playwright-core": "1.52.0" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" } }, - "playwright-core": { - "version": "1.39.0", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.39.0.tgz", - "integrity": "sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==", - "dev": true + "node_modules/playwright-core": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.52.0.tgz", + "integrity": "sha512-l2osTgLXSMeuLZOML9qYODUQoPPnUsKsb5/P6LJ2e6uPKXUdPK5WYhN4z03G+YNbWmGDY4YENauNu4ZKczreHg==", + "dev": true, + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } }, - "prettier": { + "node_modules/prettier": { "version": "2.8.8", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", - "dev": true + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } }, - "ps-tree": { + "node_modules/ps-tree": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/ps-tree/-/ps-tree-1.2.0.tgz", "integrity": "sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA==", "dev": true, - "requires": { + "dependencies": { "event-stream": "=3.3.4" + }, + "bin": { + "ps-tree": "bin/ps-tree.js" + }, + "engines": { + "node": ">= 0.10" } }, - "rimraf": { + "node_modules/rimraf": { "version": "2.5.4", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.5.4.tgz", "integrity": "sha512-Lw7SHMjssciQb/rRz7JyPIy9+bbUshEucPoLRvWqy09vC5zQixl8Uet+Zl+SROBB/JMWHJRdCk1qdxNWHNMvlQ==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", "dev": true, - "requires": { + "dependencies": { "glob": "^7.0.5" + }, + "bin": { + "rimraf": "bin.js" } }, - "split": { + "node_modules/split": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", "integrity": "sha512-wD2AeVmxXRBoX44wAycgjVpMhvbwdI2aZjCkvfNcH1YqHQvJVa1duWc73OyVGJUc05fhFaTZeQ/PYsrmyH0JVA==", "dev": true, - "requires": { + "dependencies": { "through": "2" + }, + "engines": { + "node": "*" } }, - "stream-combiner": { + "node_modules/stream-combiner": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", "integrity": "sha512-rT00SPnTVyRsaSz5zgSPma/aHSOic5U1prhYdRy5HS2kTZviFpmDgzilbtsJsxiroqACmayynDN/9VzIbX5DOw==", "dev": true, - "requires": { + "dependencies": { "duplexer": "~0.1.1" } }, - "temp-fs": { + "node_modules/temp-fs": { "version": "0.9.9", "resolved": "https://registry.npmjs.org/temp-fs/-/temp-fs-0.9.9.tgz", "integrity": "sha512-WfecDCR1xC9b0nsrzSaxPf3ZuWeWLUWblW4vlDQAa1biQaKHiImHnJfeQocQe/hXKMcolRzgkcVX/7kK4zoWbw==", "dev": true, - "requires": { + "dependencies": { "rimraf": "~2.5.2" + }, + "engines": { + "node": ">=0.8.0" } }, - "through": { + "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, - "wrappy": { + "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", diff --git a/package.json b/package.json index 0499fe7..cfe8877 100644 --- a/package.json +++ b/package.json @@ -6,15 +6,16 @@ "scripts": { "sample-local-test": "BROWSERSTACK_LOCAL=true npx playwright test tests/local_test.js", "sample-test": "npx playwright test tests/sample_test.js", - "mobile-test": "npx playwright test tests/sample_test.js --project='chrome@Samsung Galaxy S22:13@browserstack-mobile'" + "mobile-test": "npx playwright test tests/sample_test.js --project='chrome@Samsung Galaxy S22:13@browserstack-android'", + "ios-test": "npx playwright test tests/sample_test.js --project='safari@iPhone 16:18@browserstack-ios'" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { - "@playwright/test": "1.39.0", + "@playwright/test": "latest", "browserstack-local": "^1.5.1", - "playwright": "1.39.0", + "playwright": "latest", "prettier": "2.8.8" } } diff --git a/playwright.config.js b/playwright.config.js index ab1b7f2..5711ed7 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -66,13 +66,20 @@ const config = { }, }, { - name: "chrome@Samsung Galaxy S22:13@browserstack-mobile", + name: "chrome@Samsung Galaxy S22:13@browserstack-android", use: { baseURL: "https://www.bstackdemo.com/", browserName: "chromium", channel: "chrome", }, }, + { + name: "safari@iPhone 16:18@browserstack-ios", + use: { + browserName: "chromium", + channel: "chrome", + }, + }, ], /* Folder for test artifacts such as screenshots, videos, traces, etc. */ diff --git a/tests/local_test.js b/tests/local_test.js index 6923f26..9bdc2b6 100644 --- a/tests/local_test.js +++ b/tests/local_test.js @@ -11,6 +11,8 @@ test("Local Testing", async ({ page }, testInfo) => { await page.goto("http://localhost:5500/"); + await page.waitForTimeout(5000); + await page.evaluate((_) => {}, `browserstack_executor: ${JSON.stringify({ action: "setSessionStatus", arguments: { status: "passed", reason: "Local success" } })}`); } catch (e) { diff --git a/tests/sample_test.js b/tests/sample_test.js index 6b55f16..5602f97 100644 --- a/tests/sample_test.js +++ b/tests/sample_test.js @@ -8,15 +8,14 @@ test("BstackDemo Add to cart", async ({ page }, testInfo) => { `browserstack_executor: ${JSON.stringify({ action: "setSessionName", arguments: { name: testInfo.project.name } })}`); await page.waitForTimeout(5000); - await page.goto("https://www.bstackdemo.com/", { - waitUntil: "networkidle", - }); + await page.goto("https://www.bstackdemo.com/"); + await page.waitForTimeout(5000); await page.locator('[id="\\32 "]').getByText("Add to cart").click(); await page.getByText("Checkout").click(); await page.locator("#username svg").click(); - await page.locator("#react-select-2-option-0-0").click({ force: true }); - await page.locator("#password svg").click({ force: true }); - await page.locator("#react-select-3-option-0-0").click({ force: true }); + await page.locator("#react-select-2-option-0-0").click(); + await page.locator("#password svg").click(); + await page.locator("#react-select-3-option-0-0").click(); await page.getByRole("button", { name: "Log In" }).click(); await page.getByLabel("First Name").click(); await page.getByLabel("First Name").fill("SampleFirst"); @@ -29,6 +28,7 @@ test("BstackDemo Add to cart", async ({ page }, testInfo) => { await page.getByLabel("Postal Code").click(); await page.getByLabel("Postal Code").fill("123456"); await page.getByRole("button", { name: "Submit" }).click(); + await page.waitForTimeout(2000); await page.getByRole("button", { name: "Continue Shopping ยป" }).click(); await page.evaluate((_) => {},