mirror of
				https://github.com/microsoft/playwright-mcp.git
				synced 2025-10-12 00:25:14 +03:00 
			
		
		
		
	chore: migrate to locator._resolveSelector (#670)
This commit is contained in:
		
							
								
								
									
										27
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										27
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -13,7 +13,8 @@ | ||||
|         "commander": "^13.1.0", | ||||
|         "debug": "^4.4.1", | ||||
|         "mime": "^4.0.7", | ||||
|         "playwright": "1.54.1", | ||||
|         "playwright": "1.55.0-alpha-1752540053000", | ||||
|         "playwright-core": "1.55.0-alpha-1752540053000", | ||||
|         "ws": "^8.18.1", | ||||
|         "zod-to-json-schema": "^3.24.4" | ||||
|       }, | ||||
| @@ -23,7 +24,7 @@ | ||||
|       "devDependencies": { | ||||
|         "@eslint/eslintrc": "^3.2.0", | ||||
|         "@eslint/js": "^9.19.0", | ||||
|         "@playwright/test": "1.54.1", | ||||
|         "@playwright/test": "1.55.0-alpha-1752540053000", | ||||
|         "@stylistic/eslint-plugin": "^3.0.1", | ||||
|         "@types/chrome": "^0.0.315", | ||||
|         "@types/debug": "^4.1.12", | ||||
| @@ -292,13 +293,13 @@ | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@playwright/test": { | ||||
|       "version": "1.54.1", | ||||
|       "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.54.1.tgz", | ||||
|       "integrity": "sha512-FS8hQ12acieG2dYSksmLOF7BNxnVf2afRJdCuM1eMSxj6QTSE6G4InGF7oApGgDb65MX7AwMVlIkpru0yZA4Xw==", | ||||
|       "version": "1.55.0-alpha-1752540053000", | ||||
|       "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.55.0-alpha-1752540053000.tgz", | ||||
|       "integrity": "sha512-lpiGWId9fRQMn8IXR3Bimbpn/6PLlM2rwn3eWg58BO4X+JjAWXHVmBHvbIkAqfR4v5rxzAJIMQi2XHvPsur3YA==", | ||||
|       "dev": true, | ||||
|       "license": "Apache-2.0", | ||||
|       "dependencies": { | ||||
|         "playwright": "1.54.1" | ||||
|         "playwright": "1.55.0-alpha-1752540053000" | ||||
|       }, | ||||
|       "bin": { | ||||
|         "playwright": "cli.js" | ||||
| @@ -3300,12 +3301,12 @@ | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/playwright": { | ||||
|       "version": "1.54.1", | ||||
|       "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.54.1.tgz", | ||||
|       "integrity": "sha512-peWpSwIBmSLi6aW2auvrUtf2DqY16YYcCMO8rTVx486jKmDTJg7UAhyrraP98GB8BoPURZP8+nxO7TSd4cPr5g==", | ||||
|       "version": "1.55.0-alpha-1752540053000", | ||||
|       "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.55.0-alpha-1752540053000.tgz", | ||||
|       "integrity": "sha512-Nk6feSnITP79R936KspfwS5MrhbMTK+oK8en2O/mI3lHyAiiBOh8JfOwdvRLna33E7p9KVRWXM7DbdGmFXovAQ==", | ||||
|       "license": "Apache-2.0", | ||||
|       "dependencies": { | ||||
|         "playwright-core": "1.54.1" | ||||
|         "playwright-core": "1.55.0-alpha-1752540053000" | ||||
|       }, | ||||
|       "bin": { | ||||
|         "playwright": "cli.js" | ||||
| @@ -3318,9 +3319,9 @@ | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/playwright-core": { | ||||
|       "version": "1.54.1", | ||||
|       "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.54.1.tgz", | ||||
|       "integrity": "sha512-Nbjs2zjj0htNhzgiy5wu+3w09YetDx5pkrpI/kZotDlDUaYk0HVA5xrBVPdow4SAUIlhgKcJeJg4GRKW6xHusA==", | ||||
|       "version": "1.55.0-alpha-1752540053000", | ||||
|       "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.55.0-alpha-1752540053000.tgz", | ||||
|       "integrity": "sha512-ZQaYt7sduxL1NaVfTg8oJdYGzt5XbFVVhdkuaofjwmsr8Yf245rZybb5YuhAwRT2h0MNJUH4UOdboQNDb6mqmw==", | ||||
|       "license": "Apache-2.0", | ||||
|       "bin": { | ||||
|         "playwright-core": "cli.js" | ||||
|   | ||||
| @@ -40,14 +40,15 @@ | ||||
|     "commander": "^13.1.0", | ||||
|     "debug": "^4.4.1", | ||||
|     "mime": "^4.0.7", | ||||
|     "playwright": "1.54.1", | ||||
|     "playwright": "1.55.0-alpha-1752540053000", | ||||
|     "playwright-core": "1.55.0-alpha-1752540053000", | ||||
|     "ws": "^8.18.1", | ||||
|     "zod-to-json-schema": "^3.24.4" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@eslint/eslintrc": "^3.2.0", | ||||
|     "@eslint/js": "^9.19.0", | ||||
|     "@playwright/test": "1.54.1", | ||||
|     "@playwright/test": "1.55.0-alpha-1752540053000", | ||||
|     "@stylistic/eslint-plugin": "^3.0.1", | ||||
|     "@types/chrome": "^0.0.315", | ||||
|     "@types/debug": "^4.1.12", | ||||
|   | ||||
| @@ -14,6 +14,9 @@ | ||||
|  * limitations under the License. | ||||
|  */ | ||||
|  | ||||
| // @ts-ignore | ||||
| import { asLocator } from 'playwright-core/lib/utils'; | ||||
|  | ||||
| import type * as playwright from 'playwright'; | ||||
| import type { Context } from '../context.js'; | ||||
| import type { Tab } from '../tab.js'; | ||||
| @@ -79,11 +82,10 @@ export function sanitizeForFilePath(s: string) { | ||||
|  | ||||
| export async function generateLocator(locator: playwright.Locator): Promise<string> { | ||||
|   try { | ||||
|     return await (locator as any)._generateLocatorString(); | ||||
|     const { resolvedSelector } = await (locator as any)._resolveSelector(); | ||||
|     return asLocator('javascript', resolvedSelector); | ||||
|   } catch (e) { | ||||
|     if (e instanceof Error && /locator._generateLocatorString: No element matching locator/.test(e.message)) | ||||
|       throw new Error('Ref not found, likely because element was removed. Use browser_snapshot to see what elements are currently on the page.'); | ||||
|     throw e; | ||||
|     throw new Error('Ref not found, likely because element was removed. Use browser_snapshot to see what elements are currently on the page.'); | ||||
|   } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Pavel Feldman
					Pavel Feldman